mixing macros and lisps - macro appears to unwantedly pass ; to lisp

mixing macros and lisps - macro appears to unwantedly pass ; to lisp

Gh_man
Advocate Advocate
1,352 Views
4 Replies
Message 1 of 5

mixing macros and lisps - macro appears to unwantedly pass ; to lisp

Gh_man
Advocate
Advocate

I'm attempting to mix macros and lisp code to insert blocks. I have a variable "borderscale" which (sometimes) has been set previously; if so, I'd like to use it as my scale, else I'd like to prompt the user for a scale. I've tried doing this various ways, such as:

 

^C^C-insert;blockname.dwg;\(if (> borderscale 0) borderscale (getreal));;0;

 

... which works if "borderscale" is > 0, but fails at the (getreal) stage. As best as I can make out, I think the ;'s are being passed to (getreal), rather than (getreal) actually pausing for input before processing the ;'s. I've tried this various other ways, such as replacing (getreal) with a lisp that defines "borderscale", but it fails in the same way.

 

I could do this with a lisp file, rather than having a macro run lisp code at the command line, but I'd rather have it self-contained in a macro if I can.

 

Any suggestions are appreciated.

 

0 Likes
1,353 Views
4 Replies
Replies (4)
Message 2 of 5

SeeMSixty7
Advisor
Advisor

Macros will simply send all the macro elements to the command line. There is no opportunity for a optional path or macro elements to be passed conditionally. One approach to this method is to have your macro set any variables (i.e. BlockName) you want set and then run a lisp command that uses those variables. If the variable is not set at that point, then you can simply prompt inside the lisp routine.

 

Good luck

0 Likes
Message 3 of 5

Kent1Cooper
Consultant
Consultant

How 'bout this [untested]?  Give it the 'borderscale' variable name for the scale in any case, and if it doesn't exist, the command will just prompt again for a scale.  I'm specifying the rotation of 0 ahead of the insertion-point User-input backslash, so that the scale part is at the end, and if it's going to need to prompt for that, it will be the last thing, and not thrown off by further inputs for other prompts.  [If it's something not defined for uniform scaling, you'll need to affirm the Y scale equal to the X scale with another Enter -- maybe there's a way to avoid that....]

 

^C^C-insert blockname.dwg _r 0 \!borderscale

Kent Cooper, AIA
0 Likes
Message 4 of 5

scot-65
Advisor
Advisor
Perhaps

^C^C(if (not borderscale) (setq borderscale (or (getreal "Specify Border Scale: ") 1.0)));-insert;block.dwg;\bordersacle;;0;

untested.

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 5 of 5

cadffm
Consultant
Consultant

OR will nil or t but nothing else

and typo: bordersacle

 

I would write the whole thing as Lisp expression.

^C^C(progn(or borderscale (setq borderscale (getreal "Specify Border Scale: ")) (setq borderscale 1.0))(command "_.-insert" "block.dwg" PAUSE borderscale "" "" 0))

But this is pretty ugly.

@Gh_man 

So why not define a well written function in a lisp file (defun c:

and the macro contain just the new command.

Sebastian

0 Likes