line "_non" does not work
Hi all.
line
100,0
@100,100
After drawing a single line with the above command, the following Lisp will draw it on the previously drawn line.
(defun c:test1 (/ pt1 pt2)
(setq pt1 '(98 0 0))
(setq pt2 '(98 100 0))
(command "line" pt1 pt2 "")
)
In AutoCAD
(command "line" "_non" pt1 "_non" pt2 "")
This works fine in AutoCAD, but not in BricsCAD.
How do I draw it?
Thank you.
line
100,0
@100,100
After drawing a single line with the above command, the following Lisp will draw it on the previously drawn line.
(defun c:test1 (/ pt1 pt2)
(setq pt1 '(98 0 0))
(setq pt2 '(98 100 0))
(command "line" pt1 pt2 "")
)
In AutoCAD
(command "line" "_non" pt1 "_non" pt2 "")
This works fine in AutoCAD, but not in BricsCAD.
How do I draw it?
Thank you.
0
Comments
-
It works for me, in Bricscad v17.
With or without the osnap overrides.
"After drawing a single line with the above command, the following Lisp will draw it on the previously drawn line."
I don't understand that part. If you want the function to draw the same line asline_100,0_@100,100
, then the function should be:(defun c:test1 (/ pt1 pt2) (setq pt1 '(100 0 0)) (setq pt2 '(200 100 0)) (command "line" pt1 pt2 "") )
You can put the "_non" overrides in if you want, but they don't do anything. Osnaps and overrides only affect mouse selection of pick points, not points that are specified numerically.0 -
sorry.
I misunderstood the problem.
I will sort it out and ask the question again.0 -
In my experience with programming in AutoCAD the snap overrides DO affect behavior when using the command function. Maybe not in BricsCAD but in every version of AutoCAD that I've used, I've used "_non". The alternative is to disable object snaps and error trap accordingly to make sure they are always restored. That's probably the "best" solution but maybe not so much when you're just trying to write a quick script.0
-
Yes, of course, overrides can be used with the command function, in Bricscad too.KeithsCADServices said:In my experience with programming in AutoCAD the snap overrides DO affect behavior when using the command function. ...
(command "line" "_non")
starts a line at a picked point that ignores all osnaps.But in the OP's example, the endpoints are provided as variables pt1 and pt2, so osnaps are irrelevant.
0 -
> Osnaps and overrides only affect mouse selection of pick points, not points that are specified numerically.
not correct :-)
when running commands, which use point input, via (command ...), then object snapping will affect the point, which is finally passed-on to the command :
in
(command "_line" pt1 ...)
the object snap is applied to PT1 point, and that "snapped point" (if any) is then passed-on to running LINE command ...
this is how it works in both AutoCAD + BricsCAD.
Hence, safest way is to disable + restore object snapping via OSMODE, inside the Lisp code, or use the overrieds as "_non" and similar ...
many greetings !0 -
Torsten, thanks for clearing that up. I've been working for years under a misunderstanding. I'll have to go through all my custom commands and see where those overrides may be needed.
Saitoib and Keith, sorry for the mistakes in my earlier posts.0 -
In case you opt for disabling the running osnap: never set OSMODE to 0, but switch it on and off by setting /clearing its last bit (there are plenty of old scripts around that do it the wrong way). And keep in mind that BricsCAD's behavior in this respect is governed by OSNAPCOORD.0
-
I use (setvar 'osmode 0) most times and that works 99.9 % if you want a full off use (setvar 'osmode 16384), I do a (setq oldsnap (getvar 'osmode)) at start of code then reset at end of code.
Often you want certain snaps in your code like END (setvar 'osmode 1)0 -
My custom command functions usually just prompt for user input and then pass it, along with option letters, to a built-in command. If point input is needed, I use (getpoint), and let the user determine osnap settings/overrides while picking. I didn't know, until now, that those picked points would be subject to osnap again during the (command) function. That could be a problem if the user zooms out after picking a point. Zooming out could move nearby osnap points into the theoretical pickbox centered on that picked point when the (command) function executes. So I added the "_non" override, as Saitoib did, wherever a point is passed to a command.0
-
No worries! I've been more wrong about much bigger things. I just got vla-insertBlock to finally work (no idea why it wasn't working before). Now I have to find my previous post from a few months ago and fix it :-S . When we're programming it's hard to know what's driving what. It's also important to be aware that BricsCAD might behave differently than AutoCAD (hence why I covered my butt, as I didn't know if BricsCAD and AutoCAD behaved the same in this context.Anthony Apostolaros said:Saitoib and Keith, sorry for the mistakes in my earlier posts.
0 -
Recent versions of BricsCAD now incorporate the Express Tools (ACET) library of functions. This includes functions for setting and restoring your environment.ALANH said:I use (setvar 'osmode 0) most times and that works 99.9 % if you want a full off use (setvar 'osmode 16384), I do a (setq oldsnap (getvar 'osmode)) at start of code then reset at end of code.
Often you want certain snaps in your code like END (setvar 'osmode 1)
See acet-sysvar-set & acet-sysvar-restore
Regards,
Jason Bourhill
BricsCAD V22 Ultimate
CAD Concepts0