amitbhat212 Posted February 10, 2017 Posted February 10, 2017 Hi, I have just started using autocad two weeks ago and I'm trying to make my first script file, a joined, closed polyline that is a rectangle. The code is below: _pline -15000,0 15000,0 15000,-1000 -15000,-1000 c (there is a space after the 'c' and a return after the line) When I run, it creates a trapezoid and I'm not sure why (it is joined and closed). The first and second points are in the correct locations. The third point is not (it's at (15000,-1160.7425)) and the fourth point is not (it's at (-15200,-1160.7425)). All the angles from the XY plane are 0, so none of them are going into the z dimension. Also, the problem vanishes when I remove the negative signs from the y coordinates. Does anyone know what's going on and can provide a fix? Thanks! Quote
Dadgad Posted February 10, 2017 Posted February 10, 2017 (edited) Welcome to CADTutor. Might you consider using the RECTANGLE command in your script, instead of the PLINE command? Edited February 11, 2017 by Dadgad Quote
steven-g Posted February 10, 2017 Posted February 10, 2017 First welcome to Cadtutor, and second welcome to the world of automating Autocad, your script works just fine for me, so the good news is you did it correctly. Now to figure out what went wrong, did you have any other objects in the drawing, depending on the zoom scale a script will still snap to existing geometry that is close to where your points are supposed to be, try turning off osnaps F3 before running the script. Quote
rkmcswain Posted February 10, 2017 Posted February 10, 2017 I agree about the running object snaps. Try this script osmode 0 _pline -15000,0 15000,0 15000,-1000 -15000,-1000 c Quote
Dadgad Posted February 10, 2017 Posted February 10, 2017 While turning off your osnaps works, is a great idea, and the easiest, it looks like you could also change the OSNAPCOORD setting from the default 0 to 1. Quote
steven-g Posted February 10, 2017 Posted February 10, 2017 +1 Dadgad I'll look into that one, I quite often turn off osnaps in a script as shown by rkmkswain, but in LT you have to do some funky stuff to get the proper settings back from before the script, OK if you always use the same settings but with variable osnap settings that can be a problem, having a boolean is much nicer. Quote
BIGAL Posted February 10, 2017 Posted February 10, 2017 steven-g one way maybe around the remember osnaps could be to ignore what they were and reset to your most commonly used "osmode 47" Back to the poster as they have access to lisp and using rkmcswain suggestion (setq oldsnap (getvar "osmode")) osmode 0 _pline -15000,0 15000,0 15000,-1000 -15000,-1000 c (setvar "osmode" oldsnap) Quote
amitbhat212 Posted February 12, 2017 Author Posted February 12, 2017 The rectangle command works with OSNAP on or off and the pline command works with OSNAP off. Thank you everyone! Quote
Recommended Posts
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.