Jump to content

Recommended Posts

Posted

I don't often look into this part of CADTutor, as you can see from my profile I use LT, but I have an odd idea that someone here might be able to help on this one.

I have a macro that won't cooperate, it makes use of 'cal to pick a point, I have tried everything but I can't cleanly exit the macro, it asks for the next point of the line, if I add a final ";" that would normally exit the line command, but it completely loses track of what is going on, Diesel can give similar odd results at times and it is due to the order that Autocad evaluates parts of a macro (in Diesel you can sort this using quotes) but this doesn't work for 'cal. I have seen 'cal used often in Lisp does anyone know of similar tricks that are needed to work with 'cal.

I've probably lost you by now so here is the macro

^C^C^Cpoint;\'cal;p1=[$M=$(getvar,lastpoint)];erase;last;;line;0,0;'cal;p1;

it draws a line from 0,0 to a picked point, eventually I need to extend the macro but can't get past this hurdle.

Posted

Are you saying that you have access to geomcal functions in ACAD LT ?

Posted

Yes we have the cal command and all that it can do, which works fine its just not working in the correct sequence during this exercise.

Posted

Ok try

cal "1+1"

or

'cal "1+1"

or

(cal "1+1")

 

Just to see what the syntax is

Posted

The first 2 show "Error global variable not defined" the last one lets me know that "('cal LISP command is not available"

Posted

It's definately the evaluation sequence that is giving the problem, the following macro

^C^C^Cline;'cal;(end+end)/2;\\;0,0;0,2;

runs out of order at the command line 'cal should return the first point of the line but it doesn't return the value until the macro has finished

Command: line
Specify first point: 'cal
>>>> Expression: (end+end)/2
>>>> Select entity for END snap:
>>>> Select entity for END snap:
Resuming LINE command.
Specify first point:
Specify next point or [undo]: 0,0
Specify next point or [undo]: 0,2
Specify next point or [Close/Undo]: 14.696087353094,13.027588335085,0

how do I force the 'cal command to return it's value at the correct place in the macro

Posted

After some trial and error :

 

[CAL TEST]^c^c$M=$(eval, "cal;2+2");

 

seems to return cal's function values.

 

Maybe this will help -David

Posted

I expect that you know the cal shortened expression "mee" which is the same as "(end+end)/2".

 

Just to save you a bit of typing :D

Posted

Yes I know the shortcuts, the one I actually need is ilp(p1,p2,p3,p4,p5) but but thats another story. The problem isn't really with cal, it's getting it to work within a macro that is the problem, using 'cal twice transparently inside any drawing command doesn't play nicely, it works great for a point, it's ok for picking a circle centre point, but using it with a line !!, I have a workaround that uses 3 macro's, I was hoping to get it down to just 2. first I set up my base points (p1, p2, etc), then I can run another macro that uses cal to calculate my working points (using p1 etc) to produce p10, p11 etc, then a third macro draws the lines using p10, p11---- (but I cannot exit the line command in the macro gracefully, I have to use escape), I want to combine the second 2 macro's so that I can pick eack point of a line, perform a calculation and go onto the next point without having to create the extra points p10, p11, but once the line command is started 'cal won't return it's values in the correct sequence.

Posted

Steven-g sounds like given the time involved trying to create macros may be cheaper to buy a non Autocad product that has lisp etc Have it sitting beside LT. Not sure for you how many hours add up to $299. I know how many hours I have spent going around in circles.

Posted

Unfortunately it's not my descision. Besides I love the challenge

Posted

Delving about in the Help files, I found the following

 

The following circumstances delay resumption of a menu macro:

 

If input of a point is expected, Object Snap modes may precede entry of the actual point.

If X/Y/Z point filters are used, the menu item remains suspended until the entire point has been accumulated.

If the SELECT command is used, the menu item doesn't resume until object selection has been completed.

If the user responds with a transparent command, the suspended menu macro remains suspended until the transparent command is completed and the originally requested input is received.

If the user responds by choosing another menu item (to supply options or to execute a transparent command), the original macro is suspended, and the newly selected item is processed to completion before the suspended macro is resumed.

 

It sounds as if the 'cal command has not finished when you want it to. Perhaps it might give you a train of thought :unsure:

Posted

The problem is when 'cal is called more than once transparently within another command inside a macro, I can pick a string of points using 'cal it behaves perfectly well, though I did have to include the "\" pause for user input or it gave strange results. I have the results I want, just not as cleanly as I hoped, but I can live with it, having to run the extra macro is only one click.

Thankyou to the people who have answered, I have learnt a lot, at the start of this I didn't have a working method, I do now. And I will keep trying to improve :)

Posted

Can you post your example if you can create a number of points somehow it opens up the pandora box on simple mods that would be a few lines in lisp. Polar would become a Cal vector calc.

Posted

For a known number of points I got this working

^C^Ccal;p1=cur;\cal;p2=cur;\l;'cal;p1;'cal;p2;

without the backslash it fails, but I have to pick the points first and then draw the line, what I wanted to do was pick the points as the line is being drawn but once the line command is started I just cannot get 'cal to accept user input once the line command has started. From the command line you can 'cal points of a line all day long, but in a macro once line starts you can use "\" to wait for user input but not combined with 'cal.

Even this working version isn't 100% it won't exit the macro, it always wants the next point on a line, adding ";" which would normally end the line command just makes it draw the line incorrectly (it actually makes it start the line from the last drawn line) and the line command remains active.

Posted

Maybe can you enter a diesel for the equivalent of chr(x) x is number for ESC key try also ^c, also I think chr(13)=Return Ctrl+m ?

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