Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding PLINE option to existing LISP

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
bnesja
371 Views, 2 Replies

Adding PLINE option to existing LISP

Can somebody help me modify this .lsp to work with polylines as well as lines? I don't know much about .lsp commands as this was written by somebody else. It's a neat little command but I/ we use PLINEs far more often than LINEs.

 

(defun c:picang (/ snapmode-sv unts entnam tpe pt1 pt2 ang)
(setq snapmode-sv (getvar "SNAPMODE"))
(setvar "SNAPMODE" 0)
(setq unts (getvar "AUNITS"))
(setq entnam (entsel "\nSelect a line"))
(if (null entnam) (princ "\nNothing found")
(progn ; Nothing - exit
(setq entlst (entget (car entnam)))
(setq tpe (cdr (assoc 0 entlst)))
(if (/= tpe "LINE") (princ "\nNot a line")
(progn ; No line - exit
(setq pt1 (cdr (assoc 10 entlst)))
(setq pt2 (cdr (assoc 11 entlst)))
(setq ang (angle pt1 pt2))
(setvar "cmdecho" 0)
(command "snap" "r" "" (angtos ang unts 6))
(setvar "SNAPMODE" 0)
(setq ans (getangle "\nOffset? <0>: "))
(if (null ans) ()
(progn : No offset - exit
(setq ang (+ ans ang))
(setq angstr (angtos ang 0 6))
(command "snap" "r" "" (angtos ang unts 6))
)
)
)
)
)
)
(setvar "SNAPMODE" snapmode-sv)
(princ)
)

2 REPLIES 2
Message 2 of 3
Kent1Cooper
in reply to: bnesja


@bnesja wrote:

Can somebody help me modify this .lsp to work with polylines as well as lines? ....


Since I already have something that includes not just Polylines but also a lot of other entity types [see comments at the top], here is AlignSnapAng.lsp.  It doesn't have the Offset-angle option that's in what you posted, but something like that could be added easily enough, if you use that option often enough to need it added.

 

It has two commands:  AS to merely Align the Snap angle to the direction whatever you select is headed at the selection point, without changing the SNAPBASE origin [as what you posted keeps the current base], and ASB to both Align the Snap angle and set the SNAPBASE origin to the logical point in relation to the object [also see comments at the top], or if there isn't one, the point on the object closest to where it was selected.

Kent Cooper, AIA
Message 3 of 3
bnesja
in reply to: Kent1Cooper

Kent,

This is perfect. After talking with the other Techs, they would like to have the offset feature. I tried to slip it in buuuuut that's beyond me. Thank you for all of your help. This would help us out a ton.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost