Jump to content

How to get the name of Dynamic Block ??


h_mikke

Recommended Posts

I'm Trying to get the name of Block "fix_a" as "bkname_a".

For normal block, both A and B below works, but not for dynamic block.

 

A:

(setq bkname_a (cdr (assoc 2 (entget (car fix_a)))))

 

B:

(setq fix_an (cdr (assoc '-1 (entget (car fix_a)))))
(setq bkname_a (vla-get-name (vlax-ename->vla-object fix_an)))

 

When it comes to dynamic block, the "bkname_a" gets some string starts with "*", such as *U211, *U7.

This stirng is not the blockname, but one-to-one correspondent to the blockname.

I can't understand what's happening.

Please help me if you know how to get the name of dynamic block !!

 

 

Additionally, when I tried to use the script below, I can bet the blockname.

http://cadtips.cadalyst.com/content/block-quantify?print=1

Edited by SLW210
Link to comment
Share on other sites

With dynamic blocks the block name always starts with an *, but the "Effective Name" holds what is the block name in a normal block.

 

I'm not sure how to deal with that in LISP as I've only ever done in VBA, but no doubt one of our LISP experts will show you how it can be done. Can you use ENTSEL or ENTGET to list the DXF codes of the dynamic block and then see with which code the name you are looking for is associated?

Link to comment
Share on other sites

For dynamic block you should use it like this .

 

(vla-get-Effectivename (vlax-ename->vla-object (car (entsel "\n Select a Dynamic block :"))))

Link to comment
Share on other sites

For dynamic block you should use it like this .

 

(vla-get-Effectivename (vlax-ename->vla-object (car (entsel "\n Select a Dynamic block :"))))

 

Hope they don't miss.

Link to comment
Share on other sites

Opps ...... You may mean the variable :o

 

Huh? What variable? :huh:

 

No... I simply meant that if the user failed to select an object, let alone one without the applicable EffectiveName Property, an error will be returned.

 

Lee's already provided the solution (by way of VVA's posted links), and he's not even in this thread (yet?). LoL

Link to comment
Share on other sites

Huh? What variable? :huh:

 

No... I simply meant that if the user failed to select an object, let alone one without the applicable EffectiveName Property, an error will be returned.

 

Lee's already provided the solution (by way of VVA's posted links), and he's not even in this thread (yet?). LoL

 

The variable which is (setq ename ........

 

You're right , since the OP is already know how to handle that and just looking for the correct function , I left it for them . :)

 

Regards.

Link to comment
Share on other sites

Lee's already provided the solution (by way of VVA's posted links), and he's not even in this thread (yet?). LoL

 

No he's not in this thread yet, but you can bet your bottom dollar he's watching :roll:

Link to comment
Share on other sites

Thank you all for the advises.

Now I got the "Effective name" and that is what I needed.

 

As I'm beginner and don't understand the discussion of "variable",

You all saved me from the labyrinth !:)

Link to comment
Share on other sites

As I'm beginner and don't understand the discussion of "variable"

 

Don't feel bad - You're not the only one who didn't understand. :?

Link to comment
Share on other sites

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...