Jump to content

Looking for LISP for PLINE


tzframpton

Recommended Posts

I think I've seen it before, but basically it's a LISP that creates the mitered 90° and 45° (well, any angle ° for that matter) Pipe symbol for single line plan view on a PLINE. Attached in the image shows an example, when you draw the PLINE it puts the corresponding symbol along the run at each angle run (highlighted in Yellow). Anyone know where I can find it? Once again, greatly appreciated to anyone who can lend a helping hand. 8)

pipe.jpg

Link to comment
Share on other sites

I think I've seen it before, but basically it's a LISP that creates the mitered 90° and 45° (well, any angle ° for that matter) Pipe symbol for single line plan view on a PLINE. Attached in the image shows an example, when you draw the PLINE it puts the corresponding symbol along the run at each angle run (highlighted in Yellow). Anyone know where I can find it? Once again, greatly appreciated to anyone who can lend a helping hand. 8)

 

Here is a quick and dirty simple lisp

hope it will get you started

C'mon would't to be lazy :D

 

(defun C:demo(/ ang1 ang2 points elist endang tick p1 p1r p1u p2 p2r p2u
        p3 p4 pline pmid pt1 pt2 startang)

(setvar 'osmode 0)

(setvar 'cecolor "blue")

(setvar 'plinewid 0)

(command "._pline")

(while (= 1 (logand 1 (getvar 'cmdactive)))
 (command pause))

(setq pline  (entlast)
     points (vl-remove-if
       (function not)
       (mapcar
	 (function (lambda (x)
		     (if (= 10 (car x))
		       (cdr x))))
	 (setq elist (entget pline))
	 )
       )
     tick   25.4 ;<-- ticks length
     )

(setq startang (angle (car points) (cadr points))
     endang   (angle (nth (- (length points) 2) points) (last points))
     )

(setq p1   (polar (car points) (+ startang (/ pi 2)) (/ tick 2))
     pmid (mapcar (function (lambda (a b) (/ (+ a b) 2)))
	   (car points)
	   p1)
     p2   (polar pmid (+ startang pi) (/ tick )
     p4   (polar (car points) (- startang (/ pi 2)) (/ tick 2))
     pmid (mapcar (function (lambda (a b) (/ (+ a b) 2)))
	   (car points)
	   p4)
     p3   (polar pmid startang (/ tick )
     )

(setvar 'cecolor "cyan")

(command "_spline" p1 p2 p3 p4 "" p1 p4 "")

(setq p1   (polar (last points) (+ endang (/ pi 2)) (/ tick 2))
     pmid (mapcar (function (lambda (a b) (/ (+ a b) 2)))
	   (last points)
	   p1)
     p2   (polar pmid (+ endang pi) (/ tick )
     p4   (polar (last points) (- endang (/ pi 2)) (/ tick 2))
     pmid (mapcar (function (lambda (a b) (/ (+ a b) 2)))
	   (last points)
	   p4)
     p3   (polar pmid endang (/ tick )
     )

(command "_spline" p1 p2 p3 p4 "" p1 p4 "")

(setvar 'cecolor "yellow")

(while (> (length points) 2)
 (setq	ang1 (+ (angle (car points) (cadr points)) pi)
ang2 (angle (cadr points) (caddr points))
pt1  (polar (cadr points) ang1 tick)
p1u  (polar pt1 (+ ang1 (/ pi 2)) (/ tick 2))
p1r  (polar pt1 (- ang1 (/ pi 2)) (/ tick 2))
pt2  (polar (cadr points) ang2 tick)
p2u  (polar pt2 (+ ang2 (/ pi 2)) (/ tick 2))
p2r  (polar pt2 (- ang2 (/ pi 2)) (/ tick 2))
)
 (setvar 'plinewid (/ tick )
 (command "._pline" "_non" p1u "_non" p1r "")

 (command "._pline" "_non" p2u "_non" p2r "")

 (setq points (cdr points))
 )
(princ)
 )

 

~'J'~

Link to comment
Share on other sites

Hmmm, this just might work. I downloaded it and already made a few adjustments for it to work exactly how I need... I just need to store the OSMODE and restore it when the command ends, then get an error handler in there. I won't touch the rest till Monday when I get back to work.

 

Actually, let me work on this, and I'll post my finished code revisions when I'm done. This actually is a great learning opportunity for me.... thanks for the help. I think I can take this and finish it up. This is great learning for me too. I'll check back in Monday :)

Link to comment
Share on other sites

Hmmm, this just might work. I downloaded it and already made a few adjustments for it to work exactly how I need... I just need to store the OSMODE and restore it when the command ends, then get an error handler in there. I won't touch the rest till Monday when I get back to work.

 

Actually, let me work on this, and I'll post my finished code revisions when I'm done. This actually is a great learning opportunity for me.... thanks for the help. I think I can take this and finish it up. This is great learning for me too. I'll check back in Monday :)

 

I would be happy to see your final product :)

 

Cheers :)

 

~'J'~

Link to comment
Share on other sites

I would be happy to see your final product :)

 

Cheers :)

 

~'J'~

Well, I can do a little "code monkeying" but I'm definitely no programmer. The best LISP routine I've ever made myself was about 6 lines, lol. Anyways, about to head out of town for the weekend, I'm sure when I'm back Monday I'll have some questions.... Thanks again.

Link to comment
Share on other sites

Well, I can do a little "code monkeying" but I'm definitely no programmer. The best LISP routine I've ever made myself was about 6 lines, lol. Anyways, about to head out of town for the weekend, I'm sure when I'm back Monday I'll have some questions.... Thanks again.

 

Allright, let me know what you need to change -

I'll do it completely :)

 

~'J'~

Link to comment
Share on other sites

Allright, let me know what you need to change -

I'll do it completely :)

 

~'J'~

 

 

Sorry to report, this is what I get....

 

Command: demo

._pline

Specify start point:

Current line-width is 0.0000

Specify next point or [Arc/Halfwidth/Length/Undo/Width]:

Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:

Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:

Command: ; error: bad argument type: 2D/3D point: nil

 

blue lines, nothing else

 

:(

Link to comment
Share on other sites

Sorry to report, this is what I get....

 

Command: demo

._pline

Specify start point:

Current line-width is 0.0000

Specify next point or [Arc/Halfwidth/Length/Undo/Width]:

Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:

Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:

Command: ; error: bad argument type: 2D/3D point: nil

 

blue lines, nothing else

 

:(

 

Thanks for the testing :)

I can't change it right now, sorry

Will be do it later

 

~'J'~

Link to comment
Share on other sites

Sorry to report, this is what I get....

 

Command: demo

._pline

Specify start point:

Current line-width is 0.0000

Specify next point or [Arc/Halfwidth/Length/Undo/Width]:

Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:

Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:

Command: ; error: bad argument type: 2D/3D point: nil

 

blue lines, nothing else

 

:(

 

Try edited version

 

~'J'~

pipe.LSP

  • Thanks 1
Link to comment
Share on other sites

Try edited version

 

~'J'~

 

sorry, something still a miss... nothing but blue lines again :cry:

 

Command: pipe

._pline

Specify start point:

Current line-width is 0.0000

Specify next point or [Arc/Halfwidth/Length/Undo/Width]:

Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:

Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:

Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:

Command: bad argument type: 2D/3D point: nil._undo Current settings: Auto = On,

Control = All, Combine = Yes

Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back]

: _E

Command:

Link to comment
Share on other sites

sorry, something still a miss... nothing but blue lines again :cry:

 

 

Oops, my bad

You're right, thanks

Try edited version

Edit: I added missed double quotes at the end of code

 

~'J'~

pipe.LSP

Link to comment
Share on other sites

Oops, my bad

You're right, thanks

Try edited version

 

~'J'~

 

now I get this when loading...:(

 

Command: appload

PIPE.lsp successfully loaded.

Command: ; error: malformed string on input

Command:

Link to comment
Share on other sites

Try this Steve,

 



(defun C:pipe (/ *error* ang1 ang2 cec elist endang osm p1 p1r p1u p2 p2r p2u p3 p4
           pline pmid points pt1 pt2 pwid startang tick)
 
(defun *error*    (msg)

 (if
   (vl-position
     msg
     '("console break"
   "Function cancelled"
   "quit / exit abort"
   )
     )
    (princ "   >> Error occurs!")
    (princ msg)
    )
 (command "._undo" "_E")

 (if osm (setvar "osmode" osm))
 (if cec (setvar "cecolor" cec))
 (if pwid (setvar "plinewid" pwid))
 (setvar "cmdecho" 1)  
 )
(command "._undo" "_BE")  
(setq osm (getvar "osmode"))
(setvar "osmode" 0)
(setq cec (getvar "cecolor"))
(setvar "cecolor" "cyan")
(setq pwid (getvar "plinewid"))
(setvar "plinewid" 0)
(setvar "cmdecho" 0)
(command "._pline")

(while (= 1 (logand 1 (getvar "cmdactive")))
 (command pause))

(setq pline  (entlast)
     points (vl-remove-if
          (function not)
          (mapcar
        (function (lambda (x)
                (if (= 10 (car x))
                  (cdr x))))
        (setq elist (entget pline))
        )
          )
     tick   2.5 ;<-- ticks length
     )
(command "._zoom" "_O" pline "")
(setq startang (angle (car points) (cadr points))
     endang   (angle (nth (- (length points) 2) points) (last points))
     )

(setq p1   (polar (car points) (+ startang (/ pi 2)) (/ tick 2))
     pmid (mapcar (function (lambda (a b) (/ (+ a b) 2)))
          (car points)
          p1)
     p2   (polar pmid (+ startang pi) (/ tick )
     p4   (polar (car points) (- startang (/ pi 2)) (/ tick 2))
     pmid (mapcar (function (lambda (a b) (/ (+ a b) 2)))
          (car points)
          p4)
     p3   (polar pmid startang (/ tick )
     )

(setvar "cecolor" "blue")

(command "_spline" "_non" p1 "_non" p2 "_non" p3 "_non" p4 "" "" "")
 
(setq p1   (polar (last points) (+ endang (/ pi 2)) (/ tick 2))
     pmid (mapcar (function (lambda (a b) (/ (+ a b) 2)))
          (last points)
          p1)
     p2   (polar pmid (+ endang pi) (/ tick )
     p4   (polar (last points) (- endang (/ pi 2)) (/ tick 2))
     pmid (mapcar (function (lambda (a b) (/ (+ a b) 2)))
          (last points)
          p4)
     p3   (polar pmid endang (/ tick )
     )
(command "_spline" "_non" p1 "_non" p2 "_non" p3 "_non" p4 "" "" "")

(setvar "cecolor" "yellow")

(while (> (length points) 2)
 
 (setq    ang1 (+ (angle (car points) (cadr points)) pi)
   ang2 (angle (cadr points) (caddr points))
   pt1  (polar (cadr points) ang1 tick)
   p1u  (polar pt1 (+ ang1 (/ pi 2)) (/ tick 2))
   p1r  (polar pt1 (- ang1 (/ pi 2)) (/ tick 2))
   pt2  (polar (cadr points) ang2 tick)
   p2u  (polar pt2 (+ ang2 (/ pi 2)) (/ tick 2))
   p2r  (polar pt2 (- ang2 (/ pi 2)) (/ tick 2))
   )
 (setvar "plinewid" (/ tick )
 
 (command "._pline" "_non" p1u "_non" p1r "")

 (command "._pline" "_non" p2u "_non" p2r "")

 (setq points (cdr points))
 )
 (*error* "")
(princ)
 )
(princ "\n\t\t***\tType PIPE to execute\t***")
(princ)




Link to comment
Share on other sites

now I get this when loading...:(

 

Command: appload

PIPE.lsp successfully loaded.

Command: ; error: malformed string on input

Command:

Sorry,

Missed double quotes in command prompt at the

end of code (I wrote it right here)

 

(princ "\n\t\t***\tType PIPE to execute\t***")

 

Try again, please :)

 

~'J'~

Link to comment
Share on other sites

Sorry,

Missed double quotes in command prompt at the

end of code (I wrote it right here)

 

(princ "\n\t\t***\tType PIPE to execute\t***")

 

Try again, please :)

 

~'J'~

sameo sameo, problem still there

I've been looking through _sysvdlg to see if anything is amiss, I can't find where a setting has upset something in my Acad8, even reboot and start acad from scratch..

this is still the message ...

Command: pipe

._undo Current settings: Auto = On, Control = All, Combine = Yes

Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back]

: _BE

ready to give up... thanks for trying, I'm stumped.. others having any problems with Acad8 ??

s

Link to comment
Share on other sites

sameo sameo, problem still there

I've been looking through _sysvdlg to see if anything is amiss, I can't find where a setting has upset something in my Acad8, even reboot and start acad from scratch..

this is still the message ...

Command: pipe

._undo Current settings: Auto = On, Control = All, Combine = Yes

Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back]

: _BE

ready to give up... thanks for trying, I'm stumped.. others having any problems with Acad8 ??

s

 

Yes, that's correct - did you try clicking on the screen at that point?

Link to comment
Share on other sites

Yes, that's correct - did you try clicking on the screen at that point?

 

Yep, starts the pline command and then when two or more lines are drawn, hitting enter produces a zoom extents, and thats it.

Link to comment
Share on other sites

  • 13 years later...

Another modification please, for an existing polyline, the user enter the thickness and length of the dash , as well as the length of the cutting symbol , user can enteter distance from each vertics to insert ,   user can choose the location to insert cut symbole  , either the beginning or the end of the polyline, or the beginning and the end together

Link to comment
Share on other sites

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