h_mikke Posted July 12, 2011 Share Posted July 12, 2011 (edited) 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 July 12, 2011 by SLW210 Quote Link to comment Share on other sites More sharing options...
Tyke Posted July 12, 2011 Share Posted July 12, 2011 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? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 12, 2011 Share Posted July 12, 2011 For dynamic block you should use it like this . (vla-get-Effectivename (vlax-ename->vla-object (car (entsel "\n Select a Dynamic block :")))) Quote Link to comment Share on other sites More sharing options...
VVA Posted July 12, 2011 Share Posted July 12, 2011 Effective Block Name ( Visual LISP and Vanilla LISP ) Get True Block Name (Vanilla / Visual) Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 12, 2011 Share Posted July 12, 2011 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. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 12, 2011 Share Posted July 12, 2011 Hope they don't miss. Opps ...... You may mean the variable Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 12, 2011 Share Posted July 12, 2011 Opps ...... You may mean the variable Huh? What variable? 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 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 12, 2011 Share Posted July 12, 2011 Huh? What variable? 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. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 12, 2011 Share Posted July 12, 2011 Meh - I'm leaving this alone. :sigh: Quote Link to comment Share on other sites More sharing options...
Tyke Posted July 12, 2011 Share Posted July 12, 2011 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 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 12, 2011 Share Posted July 12, 2011 No he's not in this thread yet, but you can bet your bottom dollar he's watching :wink: ...... Quote Link to comment Share on other sites More sharing options...
h_mikke Posted July 12, 2011 Author Share Posted July 12, 2011 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 ! Quote Link to comment Share on other sites More sharing options...
SLW210 Posted July 12, 2011 Share Posted July 12, 2011 h_mikke, please use code tags in the future. CODE POSTING GUIDELINES Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 12, 2011 Share Posted July 12, 2011 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. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 12, 2011 Share Posted July 12, 2011 Why did not you ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.