Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Insert block name as attribute

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
jonmcfarlandGY
420 Views, 6 Replies

Insert block name as attribute

My AutoLISP is a bit rusty so I apologize if this has an easy answer.

 

I'm trying to write a routine that lets the user select block A and then inserts block B (a tag) using block A's name and the (only) attribute.  I've managed to extract the first block's name using:

 

       (setq ent (nentsel))

       (setq blk-name (vla-get-EffectiveName (vlax-ename->vla-object (last (last ent)))))

 

But when I try to insert the block, I can't get block A's name (as returned by blk-name) as the attribute text using

 

       (Command -insert _tag-part 0,0,0 48 48 0 blk-name)

 

   it fails.  I think the attribute parameter (blk-name) is causing the problem because it's not in the form of a string.  Any suggestions to get this to work?

 

Thanks,

 

Jon

Jon

Please select "Accept as Solution" if your question was answered
6 REPLIES 6
Message 2 of 7
_Tharwat
in reply to: jonmcfarlandGY

For your first code to get the real name of the selected block ..

Try ...

 

(setq ent (nentsel))

       (setq blk-name (vla-get-EffectiveName (vlax-ename->vla-object (car ent))))

Message 3 of 7
jonmcfarlandGY
in reply to: _Tharwat

Thanks, but when I use

 

   (setq ent (nentsel))

       (setq blk-name (vla-get-EffectiveName (vlax-ename->vla-object (car ent))))  

 

    and pick the block "breakline it returns "Select object: ; error: ActiveX Server returned the error: unknown name:
EffectiveName"

     

When I use

    

   (setq ent (nentsel))

      (setq blk-name (vla-get-EffectiveName (vlax-ename->vla-object (last (last ent)))))


  it returns""breakline"".  Is there something going on that I'm not seeing?

 

Thanks

 

Jon

Jon

Please select "Accept as Solution" if your question was answered
Message 4 of 7
_Tharwat
in reply to: jonmcfarlandGY

You should add the following code to your file and load it to activate the Active x codes .

 

(vl-load-com)

Message 5 of 7
_Tharwat
in reply to: _Tharwat

I have just noticed that you are using the function *nentsel* which enter a definition and it is not the proper function for you needs , so just use function *entsel* instead of *nentsel*

 

Thanks

Message 6 of 7
jonmcfarlandGY
in reply to: _Tharwat

Thanks, that helped a lot.  My code needs to be fleshed out but this helped.

 

Thanks again,

 

Jpn

 

Jon

Please select "Accept as Solution" if your question was answered
Message 7 of 7
_Tharwat
in reply to: jonmcfarlandGY

You're welcome any time .

 

Tharwat

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost