Systemvars that mess with line command in lisp?

Systemvars that mess with line command in lisp?

Anonymous
Not applicable
879 Views
8 Replies
Message 1 of 9

Systemvars that mess with line command in lisp?

Anonymous
Not applicable

Hi Guys,

 

I'm dumbfounded with a simple lisp i wrote. I have it draw some lines from some points to other points from set variables and ones that change.

Every single time i reload the lisp in autocad i either get my lines how i want them, straight, but then other times i get them diagonal completely wrong.

I already set cmdecho to "0" that fixed it partially, but now i still sometimes get that problem.

So i was wondering if there was some other systemvars that can mess with the Line command.

 

This is a snippet from my code how i draw my lines. Not allowed to post my full code , sorry 😞

 

	(command "_line" ptnf   (polar ptnf 0 ptnf1)
				(polar (getvar 'lastpoint) (angle ptnf3 start3) ptnf2)
				ptnf3
		""
	);end command line

Hope any has any ideas why this is.

 

thanks, 

 

Bob

0 Likes
Accepted solutions (1)
880 Views
8 Replies
Replies (8)
Message 2 of 9

hmsilva
Mentor
Mentor
Accepted solution

@Anonymous wrote:

Hi Guys,

 

I'm dumbfounded with a simple lisp i wrote. I have it draw some lines from some points to other points from set variables and ones that change.

Every single time i reload the lisp in autocad i either get my lines how i want them, straight, but then other times i get them diagonal completely wrong.

I already set cmdecho to "0" that fixed it partially, but now i still sometimes get that problem.

So i was wondering if there was some other systemvars that can mess with the Line command.

 

This is a snippet from my code how i draw my lines. Not allowed to post my full code , sorry 😞

 

	(command "_line" ptnf   (polar ptnf 0 ptnf1)
				(polar (getvar 'lastpoint) (angle ptnf3 start3) ptnf2)
				ptnf3
		""
	);end command line

Hope any has any ideas why this is.

 

thanks, 

 

Bob


Hi Bob,

as you are using command 'line', try to set OSMODE to 0 and run the code.

Made any difference?

 

Henrique

EESignature

0 Likes
Message 3 of 9

Anonymous
Not applicable

Hi Henrique,

 

Thanks for that, seems to be the one :).

Is there an explanation on the net as to why this interferes with a simple line command from point to point?

Tried a simple google seach but couldn't find the awnser.

 

Thanks again,

 

Bob

0 Likes
Message 4 of 9

hmsilva
Mentor
Mentor

@Anonymous wrote:

Hi Henrique,

 

Thanks for that, seems to be the one :).

Is there an explanation on the net as to why this interferes with a simple line command from point to point?

Tried a simple google seach but couldn't find the awnser.

 

Thanks again,

 

Bob


Bob,

all 'draw' command calls, are subjected to 'osnap mode' interference.

Is advised to store 'osmode value, set to zero, do the command 'draw' calls, reset 'osmode to the original value, or use the osmap "_NONe" just before each point in a command call. 

Or, use entmake function.

 

Henrique

EESignature

0 Likes
Message 5 of 9

Anonymous
Not applicable

Ok thanks,

 

 

0 Likes
Message 6 of 9

Kent1Cooper
Consultant
Consultant

@hmsilva wrote:
....

all 'draw' command calls, are subjected to 'osnap mode' interference.

 

....

... as well as a lot of EDITing commands [e.g. Move, Copy, Rotate, Stretch] and VIEWing commands [e.g. Zoom, Pan, UCS].  Anything you can do by picking a point on-screen for a location that at least sometimes can [even if it may not always] use pick-a-location input is subject to Object Snap if you have any running Osnap mode(s) turned on.

Kent Cooper, AIA
0 Likes
Message 7 of 9

hmsilva
Mentor
Mentor

@Kent1Cooper wrote:

@hmsilva wrote:
....

all 'draw' command calls, are subjected to 'osnap mode' interference.

 

....

... as well as a lot of EDITing commands [e.g. Move, Copy, Rotate, Stretch] and VIEWing commands [e.g. Zoom, Pan, UCS].  Anything you can do by picking a point on-screen for a location that at least sometimes can [even if it may not always] use pick-a-location input is subject to Object Snap if you have any running Osnap mode(s) turned on.


Fully agree!

 

Thank you!

Henrique

EESignature

0 Likes
Message 8 of 9

scot-65
Advisor
Advisor
I would suggest instead of OSMODE = 0
incorporated into your code to simply add
16384 to the value. That way if the program
crashes (or is prematurely canceled by the user),
while OSMODE is suppressed, the user can simply
re-enable via the status icon or the F-key.

When finished executing:
(if (>= (getvar 'OSMODE) 16384)
(setvar 'OSMODE (- (getvar 'OSMODE) 16384))
);if

???

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

0 Likes
Message 9 of 9

Kent1Cooper
Consultant
Consultant

@scot-65 wrote:
I would suggest instead of OSMODE = 0
incorporated into your code to simply add
16384 to the value. ....

When finished executing:
(if (>= (getvar 'OSMODE) 16384)
(setvar 'OSMODE (- (getvar 'OSMODE) 16384))
);if

If you're going to do it that way, you would need to check the value of the OSMODE setting before as well as after, and not simply add that to it regardless:

 

(if (< (getvar 'osmode) 16384)

  (setvar 'osmode (+ (getvar 'osmode) 16384))

)

 

because if running Osnap modes are already not on, that is, the value already has the 16384 bit in it, you'll end up with an invalid value if you just add it.

 

Another [and shorter] way to do that:

 

(setvar 'osmode (logior 16384 (getvar 'osmode)))

 

But a good error handler can ensure that it gets reset in case of error, without any of that.

Kent Cooper, AIA
0 Likes