Jump to content

Recommended Posts

Posted

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!

Posted (edited)

Welcome to CADTutor. :)

Might you consider using the RECTANGLE command in your script, instead of the PLINE command?

Edited by Dadgad
Posted

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.

Posted

I agree about the running object snaps.

 

Try this script

 

osmode
0
_pline
-15000,0
15000,0
15000,-1000
-15000,-1000
c

Posted

While turning off your osnaps works, is a great idea, and the easiest, :beer:

it looks like you could also change the OSNAPCOORD setting from the default 0 to 1.

osnapcoord.JPG

Posted

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

Posted

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)

Posted

The rectangle command works with OSNAP on or off and the pline command works with OSNAP off.

 

Thank you everyone!

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