Jump to content

Dynamic block and Autolisp & DXF


Recommended Posts

Posted

Is it possible to retrieve the name of a visibility state from a Dynamic Block?

 

I want a lisp that I can click on a block and then draw a leader and fill an attribute block with the block name.

 

I was able to make it work with a simple block but what of a Dynamic Block?

 

the DXF grp code "2" where the name of the block normally is just shows a "*U2" when it's a Dynamic block.

 

any ideas? Thanks in advance

Posted

Q1

Is it possible to retrieve the name of a visibility state from a Dynamic Block?
I can't take credit for this... posted by drsvsmani on Autodesk Discussion Groups

(defun DynamicProps (ename propname value / obj prpL cla cll prp)
(setq obj (if (= (type ename) 'VLA-OBJECT) ename (vlax-ename->vla-object ename)))
(setq prpL (vlax-invoke obj 'getdynamicblockproperties))
(setq return
(if (setq prp (vl-remove-if-not (function (lambda(x)(= (vlax-get-property x 'PropertyName) propname))) prpL))
(mapcar (function (lambda(v)
(if (and (/= value nil)(vlax-property-available-p v 'Value)(/= (type value)'LIST))
(progn (vlax-put-property v 'Value value)(vla-update obj))
)
(if (and (vlax-property-available-p v 'AllowedValues) (vlax-get v 'AllowedValues))
(list (vlax-get v 'Value)(vlax-get v 'AllowedValues))
(vlax-get v 'Value)
)
)) prp)
(mapcar (function (lambda(v)(list (vla-get-propertyName v)(vlax-get v 'Value) v))) prpL)
)
)
return
)

(setq vs (DynamicProps (car (entsel)) "Visibility" nil))
(car (car vs));returns current visibility state

Q2

 

(vlax-get (vlax-ename->vla-object (car (entsel))) 'EffectiveName)

Posted
(defun block_name (bloc / name)
[b][color="Red"](vl-load-com)[/color][/b] 
(setq	bloc (if (eq (type bloc) 'ENAME)
       (vlax-ename->vla-object bloc)
     )
name (if (eq (type bloc) 'VLA-OBJECT)
       (cond
	 ((= (vla-get-isdynamicblock bloc) :vlax-true)
	  (vla-get-effectivename bloc)
	 )
	 (t
	  (vla-get-name bloc)
	 )
       )
     ) ;_cond
 )
)

Posted

hmm i can't get either one to work

Posted

Has forgotten to load in a code vla functions (vl-load-com)

Command: (block_name (car(entsel)))

Select object: "Geo_Point"

Geo_Point - name of the selected block

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...