Passing a lisp variable to a block attribute insterted with a menu macro

Passing a lisp variable to a block attribute insterted with a menu macro

Anonymous
Not applicable
1,553 Views
10 Replies
Message 1 of 11

Passing a lisp variable to a block attribute insterted with a menu macro

Anonymous
Not applicable

The lisp

      (setq userr1 (getreal "\n Wattage?"))

 

The menu macro

 

[MVDEC_009,DEC SF MTD]^C^C^P-insert MVDEC_009 \!userr5 ;\;;;!userr1 ;;;;;;;;;;;;;;;;;;;;;;;^P

 

the block has 26 tags. The Wattage tag is fourth.

 

!userr5 is a scaling value for the block and works fine but !userr1 comes in as text instead of the value ie 40.4

 

Also do I have to use one of the global variables like userr1 or can I use a normal variable like wts

 

I have searched for a solution here but not found one.

0 Likes
Accepted solutions (1)
1,554 Views
10 Replies
Replies (10)
Message 2 of 11

john.uhden
Mentor
Mentor

I am just guessing here, but since attributes are just like text, maybe you should be supplying a string value instead of a real.

Also, I don't think scripts take AutoLisp symbols.

So, how about trying...

 

(setq mts (getreal "\n Wattage?"))
(setvar "users1" (rtos mts 2 1)) ; or whatever precision you want.

Then use users1 in your script.

 

John F. Uhden

0 Likes
Message 3 of 11

Anonymous
Not applicable

I think you have hit the nail on the head yes absolutely true if you were passing a variable to a block using lisp then you would have to convert it. I will try that right after afternoon coffee!

0 Likes
Message 4 of 11

Anonymous
Not applicable

Nope I have tried some variations and it's still not working

this works for the scale

 So in this case it's asking for a scale factor and accepts

 

ID_Ps100  [Plot Scale 1:100]^C^C^P(setq userr5 2) ^P

 

[MVDEC_009,DEC SF MTD]^C^C^P-insert MVDEC_009 \!userr5 ;\;;;;;;;;;;;;;;;;;;;;;;;;;;;^P

 

But I still can't pass text or a number to an attribute

 

0 Likes
Message 5 of 11

ВeekeeCZ
Consultant
Consultant
I would use a lisp instead of macro for the button.
(command "-insert" "12" pause 1 1 0 (getvar 'users1))
0 Likes
Message 6 of 11

Anonymous
Not applicable

Trouble is the block is selected from a slide as in

 

ID_Mvfits  [Insert MV Fits]^C^C^P(if (= userr5 nil)(setq userr5 1))(if (not mfitlayer)(load "mfitlayer.fas"))(mfitlayer)

 

mfitlayer is lisp making or setting the right layer current then switches to a window containing slides of the blocks

 

\^P$I=SLD.image_MVFits_New $I=SLD.*

 

so the user clicks on the slide of the block he wants then

 

**image_MVFITS_New
[MAINS VOLTAGE FITTINGS]

[MVDEC_009,DEC SF MTD]^C^C^P-insert MVDEC_009 \!userr5 ;\;;;users1 ;;;;;;;;;;;;;;;;;;;;;;;^P

 

which inserts the block on the right layer at the right scale and hopefully the correct wattage in the fouth attribute tag.

 

 

0 Likes
Message 7 of 11

ВeekeeCZ
Consultant
Consultant

How about insert a block using macro without attributes and then run a lisp which put attributes back on the block just created? Something like (setattributes (entlast) (getvar 'users1)) - some routine for that you can find on Lee's page HERE

...because I don't think we can find the way to evaluate the variable (or a lisp code) right away.

0 Likes
Message 8 of 11

Anonymous
Not applicable

Maybe after inserting the block with a default value of zero for watts then run a lisp to select last object (the block) and insert the value into the tag in the normal way with lisp? Provided I can call the lisp with the macro after inserting the block.  Messy though.

0 Likes
Message 9 of 11

ВeekeeCZ
Consultant
Consultant

Yes, that's what I meat - you can set 'attreq 0 to get no att prompts... or just put a proper mount of ;;;

0 Likes
Message 10 of 11

Kent1Cooper
Consultant
Consultant
Accepted solution

If you set the TEXTEVAL System Variable to 1, you can feed text contents from any variable [whether one of the USERSx ones or your own] into a command macro in either of two ways:

 

!YourVariableName

 

or

 

(eval YourVariableName)

Kent Cooper, AIA
Message 11 of 11

Anonymous
Not applicable

Thanks Kent! at last it's working and good to know how to do it as it could come in useful in future.

0 Likes