CADTutor: The best free help for AutoCAD on the web

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
Go Back   AutoCAD Forums > AutoCAD > AutoLISP, VBA, the CUI & Customisation

Reply
 
Thread Tools
Old 20th Nov 2009, 05:40 pm   #1
StykFacE
Forum Deity
 
StykFacE's Avatar
 
Using: MEP 2010
 
Computer Details
 
Join Date: Mar 2006
Location: Dallas, TX - USA
Posts: 3,661
Default Looking for LISP for PLINE

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.
Attached Images
File Type: jpg pipe.jpg (14.1 KB, 77 views)

Tannar Frampton | Venture Mechanical - Dallas, TX
Engineering/Construction department | AutoCAD MEP 2010 / Revit MEP 2010
StykFacE is offline   Reply With Quote
Old 21st Nov 2009, 01:14 am   #2
fixo
Super Member
 
fixo's Avatar
 
Using: AutoCAD 2008
 
Computer Details
 
Join Date: Jul 2005
Location: Pietari, Venäjä
Posts: 932
Default

Quote:
Originally Posted by StykFacE View Post
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.
Here is a quick and dirty simple lisp
hope it will get you started
C'mon would't to be lazy

Code:
(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 8))
      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 8))
      )

(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 8))
      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 8))
      )

(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 8))
  (command "._pline" "_non" p1u "_non" p1r "")

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

  (setq points (cdr points))
  )
(princ)
  )
~'J'~

The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)
fixo is offline   Reply With Quote
Old 21st Nov 2009, 03:12 am   #3
StykFacE
Forum Deity
 
StykFacE's Avatar
 
Using: MEP 2010
 
Computer Details
 
Join Date: Mar 2006
Location: Dallas, TX - USA
Posts: 3,661
Default

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

Tannar Frampton | Venture Mechanical - Dallas, TX
Engineering/Construction department | AutoCAD MEP 2010 / Revit MEP 2010
StykFacE is offline   Reply With Quote
Old 21st Nov 2009, 12:04 pm   #4
fixo
Super Member
 
fixo's Avatar
 
Using: AutoCAD 2008
 
Computer Details
 
Join Date: Jul 2005
Location: Pietari, Venäjä
Posts: 932
Default

Quote:
Originally Posted by StykFacE View Post
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'~

The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)
fixo is offline   Reply With Quote
Old 21st Nov 2009, 03:29 pm   #5
StykFacE
Forum Deity
 
StykFacE's Avatar
 
Using: MEP 2010
 
Computer Details
 
Join Date: Mar 2006
Location: Dallas, TX - USA
Posts: 3,661
Default

Quote:
Originally Posted by fixo View Post
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.

Tannar Frampton | Venture Mechanical - Dallas, TX
Engineering/Construction department | AutoCAD MEP 2010 / Revit MEP 2010
StykFacE is offline   Reply With Quote
Old 21st Nov 2009, 03:45 pm   #6
fixo
Super Member
 
fixo's Avatar
 
Using: AutoCAD 2008
 
Computer Details
 
Join Date: Jul 2005
Location: Pietari, Venäjä
Posts: 932
Default

Quote:
Originally Posted by StykFacE View Post
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'~

The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)
fixo is offline   Reply With Quote
Old 21st Nov 2009, 05:04 pm   #7
stevesfr
Full Member
 
Using: AutoCAD 2008
 
Computer Details
 
Join Date: Jan 2009
Location: Central Illinois, USA
Posts: 94
Default

Quote:
Originally Posted by fixo View Post
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

stevesfr is offline   Reply With Quote
Old 21st Nov 2009, 06:29 pm   #8
fixo
Super Member
 
fixo's Avatar
 
Using: AutoCAD 2008
 
Computer Details
 
Join Date: Jul 2005
Location: Pietari, Venäjä
Posts: 932
Default

Quote:
Originally Posted by stevesfr View Post
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'~

The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)
fixo is offline   Reply With Quote
Old 21st Nov 2009, 10:09 pm   #9
fixo
Super Member
 
fixo's Avatar
 
Using: AutoCAD 2008
 
Computer Details
 
Join Date: Jul 2005
Location: Pietari, Venäjä
Posts: 932
Default

Quote:
Originally Posted by stevesfr View Post
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'~
Attached Files
File Type: lsp pipe.LSP (2.8 KB, 9 views)

The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)
fixo is offline   Reply With Quote
Old 22nd Nov 2009, 01:17 am   #10
stevesfr
Full Member
 
Using: AutoCAD 2008
 
Computer Details
 
Join Date: Jan 2009
Location: Central Illinois, USA
Posts: 94
Default

Quote:
Originally Posted by fixo View Post
Try edited version

~'J'~
sorry, something still a miss... nothing but blue lines again

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]
<1>: _E
Command:
stevesfr is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lisp to add & total every line/pline on a layer?? StykFacE AutoLISP, VBA, the CUI & Customisation 7 14th Nov 2009 01:24 am
lisp to put text with pline leangth above line chelsea1307 AutoLISP, VBA, the CUI & Customisation 28 2nd Jun 2009 02:48 pm
LISP to join many lines to a single 3D Pline Phiphi AutoLISP, VBA, the CUI & Customisation 3 5th Feb 2009 04:07 am
Need a code lisp sum the length of line, pline, arc.. Nad SK AutoLISP, VBA, the CUI & Customisation 2 4th Dec 2008 08:53 am
continuous pline lisp cadamrao AutoCAD General 1 21st Jan 2008 10:51 am

Why Donate?


All times are GMT +1. The time now is 02:26 pm.

RSS Feed for AutoCAD ForumsValid XHTML 1.0!Valid CSS!Creative Commons Licence