Jump to content

Linetypes and or Lisps needed


Recommended Posts

Posted

Linetypes and or Lisps needed

 

 

AutoCAD 2007

I have a quite a few tough questions/requests and I am currently looking for some lisps to solve them. I have been doing some searching online to find the lisps I need, and although I have been able to find some stuff, I still have some things that I can't seem to find exactly what I am looking for. I would like to take the opportunity ahead of time to thank every who views my questions and for any help that is given.

 

 

 

I am not sure if this is something that needs a lisp or a linetype created, but I am looking for two particular linetypes.

 

The first one is a linetype I use to draw stormwater piping with. It is composed of three lines, which at the moment I have to draw all three as seperate pieces. Basically it is a polyline in the center set to a hidden2 linetype and that has a global width set to and the other two lines are continous lines on each side of the polyline. So for example if I am looking to draw a 1' in diameter stormwater pipe, the polyline global width is set to 1.00, the distance between the two continuous lines is 1.00. So what I am looking for is to be able to have a linetype/lisp created that will ask me the polyline global width (pipe diameter) and then allow me to draw the pipe (composed of the three lines) as one line. Also because site drawings may use different scales (for example 1"=40') and the linetype is a hidden2 linetype, it would also be nice to be able to set the line type scale within the lisp

 

 

The second one is a linetype that is exactly like the one above, but the center polyline is continuous instead of hidden. I use this linetype to create outlines of buildings on site plans. The two continuous lines on each side of the continuous global width polyline, makes it easier to snap to the outter most edge of the building lines.

 

I know that such things exist, because I work with some people that have used linetypes like this a companies they have worked for in the past, but I have been unable to find them. I have included a dwg file showing the two linetypes needed, just in case I did not describe them accurately enough.

 

Is anyone up for a challenge?

Linetypes.dwg

Posted

You have 2008 so you must have Express Tools. Use the Make Linetype routine.

Posted
Is anyone up for a challenge?

 

Here's a great selection of sites where you can learn LISP:

 

Starting LISP:

 

http://www.cadtutor.net/forum/showthread.php?t=38760

 

http://www.cadtutor.net/forum/showthread.php?t=38734

 

http://www.afralisp.net/

 

http://www.jefferypsanders.com/autolisptut.html

 

http://ronleigh.info/autolisp/index.htm

 

 

More Advanced LISP Tutorials:

 

http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html

 

http://www.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/html/cltl/clm/node1.html

 

Are you up for the challenge?

Posted

Whilst I do have what you want but more advanced I can not provide it because of copyright. But I can tell you how to do it.

 

in lisp (not actual code but proceedure)

 

change to pipe c/l layer

getpoint 1

getpoint 2

getreal width of pipe / 2.0

angle1 pt1-pt2

angle2 pt2-pt1

line pt1 pt2

calculate pt3 & pt4 pt5 pt6 use (polar angle1+90 angle2-90 etc) 90degs of pt1 & pt2

change layer to outside line layer

line pt3 pt4

line pt5 pt6

 

hey all done

Posted

I thank you all for your replies.

 

I tried the create the linetype i am looking for with the linetype creating express tool but I was unfortunately unsuccessful. I go through the steps and right after it asks for the starting point and ending point it asks to select objects, when I select the three lines that make up my linetype, the program returns a message something like "that's a continous linetype" and doesn't let me go any further.

 

Thank you for all the learn how to lisp links, I agree and I would like to learn, I will take a look at them. Problem is the lisps I am looking I realize are quite complex and I will probably not be able to learn how to create them any time soon.

 

Thank you for the steps to create the linetype I am looking for, but unfortunatley I do not have the experience to take these steps and apply them in a lisp.

Posted

For the amount you are looking for, you really need to learn it yourself.

Here's a great selection of sites where you can learn LISP:

 

Starting LISP:

 

http://www.cadtutor.net/forum/showthread.php?t=38760

 

http://www.cadtutor.net/forum/showthread.php?t=38734

 

http://www.afralisp.net/

 

http://www.jefferypsanders.com/autolisptut.html

 

http://ronleigh.info/autolisp/index.htm

 

 

More Advanced LISP Tutorials:

 

http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html

 

http://www.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/html/cltl/clm/node1.html

 

Are you up for the challenge?

Posted

Thanks again to everyone who has viewed and responded.

Just wondering if anybody else has this lisp already written or seen it on a website. I know it exists as a lisp, numerous people I have worked with all have used it. Can't seem to find this one.

Posted
Thanks again to everyone who has viewed and responded.

Just wondering if anybody else has this lisp already written or seen it on a website. I know it exists as a lisp, numerous people I have worked with all have used it. Can't seem to find this one.

 

 

I don´t know much about lisp... the demonstration is below... I made this quick approach... Once I made a lisp for quick trimming an intersection using polar points...

 

so I thought I could do soemthing similar today.. but I definitely need to read more about it... anyway.. it is a start for someone else to finish it...

 

type storm1 and pick 2 points... it doesn´t work completely right now.. but surely someone will fix it.

 

;will draw a single line composed of three lines, width is equal to 1
;base=1"
;it may contain extra code for any pipe size 
(defun C:storm1 ()
(setq om (getvar "osmode"))
(setq or (getvar "orthomode"))
(setvar "cmdecho" 0)
(setq p1 (getpoint "\nPick first point.. "))
(setq p2 (getpoint "\nPick second point.. "))
(setvar "osmode" 0)
(setvar "orthomode" 0)
(command "ucs" pt1 pt2 "")
(setq p3 (polar p1 90 0.5))
(setq p5 (polar p1 270 0.5))
(setq p4 (polar p2 90 0.5))
(setq p6 (polar p2 270 0.5))
(command "line" p3 p4 "")
(command "line" p5 p6 "")
(command "_.-linetype" "load" "hidden2" (strcat "C:/archivos de programa/AutoCAD 2009/UserDataCache/Support/acad.lin") "" "")
(command "_.-linetype" "set" "hidden2" "")
(command "pline" p1 "W" "1" "1" p2 "")
(command "_.-linetype" "set" "bylayer" "")
(command "ucs" "w")
(setvar "osmode" om)
(setvar "orthomode" or)
(setvar "cmdecho" 1)
(princ)
)

storm1.jpg

  • Like 1
Posted

The second code PSD should give you what you want. :)

 

;original coding taken from Pipe.lsp, created by Tim Wilson (9.11.95, revised 6.22.97)
;modified by alan thompson (11.18.08) for use at Capital Engineering and Surveying, Inc.
;    1. created 2 routines (SSD & PSD)
;        a. SSD will create an existing (Survey) storm pipe on the "V-STRM-PIPE" layer with a hidden2 linetype.
;           (if layer and/or linetype do not exist, they are created/loaded)
;        b. PSD will create a proposed (Engineering) storm pipe on the "C-STRM-PIPE" layer with a continuous linetype.
;           (if layer and/or linetype do not exist, they are created/loaded)
;    2. added error handler
;    3. removed unnecessary code, formatted and cleaned up code
;    4. localized subroutines
;thank you Tim Wilson for the borrowed coding.

;;Survey STORM
(defun C:SSD (/ *error* DTR PNT1 PNT2 D D2 A ET HD L1 L2 L3 L4 OTM c_layer my_linfile my_layer my_color my_ltype )
(vl-load-com)
;;;;;SUB ROUTINES;;;;;
(defun *error* (msg)
msg
(setvar "clayer" c_layer)
(setvar "orthomode" OTM)
);defun

(defun DTR (a)
(* PI (/ A 180.0))
)
;;;;;MAIN ROUTINE;;;;;

(setq my_linfile "CES.lin")    ;linetype file to reference (if using default acad.lin, set as: nil)
(setq my_layer "V-STRM-PIPE")    ;layer to use
(setq my_color 172)        ;color to use
(setq my_ltype "hidden2")    ;linetype to use

(setq c_layer (getvar "clayer"))
(setq OTM (getvar "orthomode"))
(setvar "cmdecho" 0)
(setvar "orthomode" 0)
(if (and
      (not (= my_linfile nil))
      (findfile my_linfile)
      (not (tblsearch "ltype" my_ltype))
    );and
     (vl-cmdf "_.linetype" "_l" my_ltype my_linfile "")
);if
(if (and
      (setq PNT1 (getpoint "\nPick Start of Pipe: "))
      (setq PNT2 (getpoint pnt1 "\nPick End of Pipe: "))
      (setq D (getdist "\nEnter Pipe Width: ")) ;In INCHES IE 24", 30", 42" SO ON
    );and
      (progn
        (if (tblsearch "layer" my_layer)
          (vl-cmdf "_.layer" "_t" my_layer "_m" my_layer "_c" my_color my_layer "_lt" my_ltype my_layer "")
          (vl-cmdf "_.layer" "_m" my_layer "_c" my_color my_layer "_lt" my_ltype my_layer "")
        );if
        (setq D2 (/ D 12))
        (SETQ D D2)
        (while Pnt2
          (setq HD (/ D 2))
          (setq A (angle PNT1 PNT2))
          (setq ET (entlast))
          (setq L1 (polar pnt1 (- a (dtr 90)) HD))
          (setq L2 (polar pnt2 (- a (dtr 90)) HD))
          (setq L3 (polar pnt1 (+ a (dtr 90)) HD))
          (setq L4 (polar pnt2 (+ a (dtr 90)) HD))
          (vl-cmdf "_.line" "_non" L1 "_non" L2 "" "_.line" "_non" L3 "_non" L4 "")
          (setq PNT1 PNT2)
          (setq PNT2 (getpoint PNT1 "\nNext Point: <Return or Enter to Quit> "))
        );while
        (setvar "clayer" c_layer)
        (setvar "orthomode" OTM)
      );progn
);if
(princ)
);defun



;;Proposed STORM
(defun C:PSD (/ *error DTR PNT1 PNT2 D D2 A ET HD L1 L2 L3 L4 OTM c_layer my_linfile my_layer my_color my_ltype my_ltype_mid )
(vl-load-com)
;;;;;SUB ROUTINES;;;;;
(defun *error* (msg)
msg
(setvar "clayer" c_layer)
(setvar "orthomode" OTM)
);defun

(defun DTR (a)
(* PI (/ A 180.0))
)
;;;;;MAIN ROUTINE;;;;;

(setq my_linfile nil)        ;linetype file to reference (if using default acad.lin, set as: nil)
(setq my_layer "C-STRM-PIPE")    ;layer to use
(setq my_color 2)        ;color to use
(setq my_ltype "continuous")    ;linetype to use for exterior lines
(setq my_ltype_mid "hidden")    ;linetype to use for interior line (pline with width of pipe)

(setq c_layer (getvar "clayer"))
(setq OTM (getvar "orthomode"))
(setvar "cmdecho" 0)
(setvar "orthomode" 0)

;load my_ltype
(if (and
      (not (= my_linfile nil))
      (findfile my_linfile)
      (not (tblsearch "ltype" my_ltype))
    );and
     (vl-cmdf "_.linetype" "_l" my_ltype my_linfile "")
);if

;load my_ltype_mid
(if (and
      (not (= my_linfile nil))
      (findfile my_linfile)
      (not (tblsearch "ltype" my_ltype_mid))
    );and
     (vl-cmdf "_.linetype" "_l" my_ltype_mid my_linfile "")
);if
(if (and
      (setq PNT1 (getpoint "\nPick Start of Pipe: "))
      (setq PNT2 (getpoint PNT1 "\nPick End of Pipe: "))
      (setq D (getdist "\nEnter Pipe Width: ")) ;In INCHES IE 24", 30", 42" SO ON
    );and
      (progn
        (if (tblsearch "layer" my_layer)
          (vl-cmdf "_.layer" "_t" my_layer "_m" my_layer "_c" my_color my_layer "_lt" my_ltype my_layer "")
          (vl-cmdf "_.layer" "_m" my_layer "_c" my_color my_layer "_lt" my_ltype my_layer "")
        );if
        (setq D2 (/ D 12))
        (setq D D2)
        (while Pnt2
           (setq HD (/ D 2))
           (setq A (angle PNT1 PNT2))
           (vl-cmdf "_.pline" "non" PNT1 "non" PNT2 "")
           (setq ET (entlast))
           (setq L1 (polar pnt1 (- a (dtr 90)) HD))
           (setq L2 (polar pnt2 (- a (dtr 90)) HD))
           (setq L3 (polar pnt1 (+ a (dtr 90)) HD))
           (setq L4 (polar pnt2 (+ a (dtr 90)) HD))
           (vl-cmdf "_.line" "non" L1 "non" L2 "" "line" "non" L3 "non" L4 "")
           (vl-cmdf "_.change" ET "" "_p" "_lt" my_ltype_mid "") ;change linetype to suit
           (vl-cmdf "_.pedit" ET "_w" D "")
           (setq PNT1 PNT2)
           (setq PNT2 (getpoint PNT1 "\nNext Point: <Return or Enter to Quit>: "))
        );while
      );progn
);if
(setvar "orthomode" OTM)
(setvar "clayer" c_layer)
(princ)
);defun

  • Like 1
Posted

see, my coding isn´t that bad...

 

 

(My coding definitively stinks)

Posted

A word of caution in the prior lisp code there was a polar command and it used 90 and 270 not sure about this, it should always for reliability be in radians 1.5704 3.1417 4.712 and a real gotcha angles are always East is 0 and anticlockwise

 

also (dtr 90) is 1.507 may confuse new forum searchers who dont know that dtr is degrees to radians sub function that the user must create

Posted
A word of caution in the prior lisp code there was a polar command and it used 90 and 270 not sure about this, it should always for reliability be in radians 1.5704 3.1417 4.712 and a real gotcha angles are always East is 0 and anticlockwise

True, but the 90 is fed through a degrees to radians subroutine.

Posted

also (dtr 90) is 1.507 may confuse new forum searchers who dont know that dtr is degrees to radians sub function that the user must create

 

It's at the beginning, right after the *error* sub.

  • 1 year later...
Posted

What do you need to change to get your lisp to work with metric units (i.e. width 0.5m instead of 24 inches etc) and not imperial alanjt? I tried changing the lines

 

(setq D2 (/ D 12))

 

to just

(setq D2 (D)

althoguh this obviously didn't work.

  • Like 1
Posted
The second code PSD should give you what you want. :)

 

;original coding taken from Pipe.lsp, created by Tim Wilson (9.11.95, revised 6.22.97)
;modified by alan thompson (11.18.08) for use at Capital Engineering and Surveying, Inc.
; 1. created 2 routines (SSD & PSD)
; a. SSD will create an existing (Survey) storm pipe on the "V-STRM-PIPE" layer with a hidden2 linetype.
; (if layer and/or linetype do not exist, they are created/loaded)
; b. PSD will create a proposed (Engineering) storm pipe on the "C-STRM-PIPE" layer with a continuous linetype.
; (if layer and/or linetype do not exist, they are created/loaded)
; 2. added error handler
; 3. removed unnecessary code, formatted and cleaned up code
; 4. localized subroutines
;thank you Tim Wilson for the borrowed coding.

;;Survey STORM
(defun C:SSD (/ *error* DTR PNT1 PNT2 D D2 A ET HD L1 L2 L3 L4 OTM c_layer my_linfile my_layer my_color my_ltype )
(vl-load-com)
;;;;;SUB ROUTINES;;;;;
(defun *error* (msg)
msg
(setvar "clayer" c_layer)
(setvar "orthomode" OTM)
);defun

(defun DTR (a)
(* PI (/ A 180.0))
)
;;;;;MAIN ROUTINE;;;;;

(setq my_linfile "CES.lin") ;linetype file to reference (if using default acad.lin, set as: nil)
(setq my_layer "V-STRM-PIPE") ;layer to use
(setq my_color 172) ;color to use
(setq my_ltype "hidden2") ;linetype to use

(setq c_layer (getvar "clayer"))
(setq OTM (getvar "orthomode"))
(setvar "cmdecho" 0)
(setvar "orthomode" 0)
(if (and
(not (= my_linfile nil))
(findfile my_linfile)
(not (tblsearch "ltype" my_ltype))
);and
(vl-cmdf "_.linetype" "_l" my_ltype my_linfile "")
);if
(if (and
(setq PNT1 (getpoint "\nPick Start of Pipe: "))
(setq PNT2 (getpoint pnt1 "\nPick End of Pipe: "))
(setq D (getdist "\nEnter Pipe Width: ")) ;In INCHES IE 24", 30", 42" SO ON
);and
(progn
(if (tblsearch "layer" my_layer)
(vl-cmdf "_.layer" "_t" my_layer "_m" my_layer "_c" my_color my_layer "_lt" my_ltype my_layer "")
(vl-cmdf "_.layer" "_m" my_layer "_c" my_color my_layer "_lt" my_ltype my_layer "")
);if
(setq D2 (/ D 12))
(SETQ D D2)
(while Pnt2
(setq HD (/ D 2))
(setq A (angle PNT1 PNT2))
(setq ET (entlast))
(setq L1 (polar pnt1 (- a (dtr 90)) HD))
(setq L2 (polar pnt2 (- a (dtr 90)) HD))
(setq L3 (polar pnt1 (+ a (dtr 90)) HD))
(setq L4 (polar pnt2 (+ a (dtr 90)) HD))
(vl-cmdf "_.line" "_non" L1 "_non" L2 "" "_.line" "_non" L3 "_non" L4 "")
(setq PNT1 PNT2)
(setq PNT2 (getpoint PNT1 "\nNext Point: <Return or Enter to Quit> "))
);while
(setvar "clayer" c_layer)
(setvar "orthomode" OTM)
);progn
);if
(princ)
);defun



;;Proposed STORM
(defun C:PSD (/ *error DTR PNT1 PNT2 D D2 A ET HD L1 L2 L3 L4 OTM c_layer my_linfile my_layer my_color my_ltype my_ltype_mid )
(vl-load-com)
;;;;;SUB ROUTINES;;;;;
(defun *error* (msg)
msg
(setvar "clayer" c_layer)
(setvar "orthomode" OTM)
);defun

(defun DTR (a)
(* PI (/ A 180.0))
)
;;;;;MAIN ROUTINE;;;;;

(setq my_linfile nil) ;linetype file to reference (if using default acad.lin, set as: nil)
(setq my_layer "C-STRM-PIPE") ;layer to use
(setq my_color 2) ;color to use
(setq my_ltype "continuous") ;linetype to use for exterior lines
(setq my_ltype_mid "hidden") ;linetype to use for interior line (pline with width of pipe)

(setq c_layer (getvar "clayer"))
(setq OTM (getvar "orthomode"))
(setvar "cmdecho" 0)
(setvar "orthomode" 0)

;load my_ltype
(if (and
(not (= my_linfile nil))
(findfile my_linfile)
(not (tblsearch "ltype" my_ltype))
);and
(vl-cmdf "_.linetype" "_l" my_ltype my_linfile "")
);if

;load my_ltype_mid
(if (and
(not (= my_linfile nil))
(findfile my_linfile)
(not (tblsearch "ltype" my_ltype_mid))
);and
(vl-cmdf "_.linetype" "_l" my_ltype_mid my_linfile "")
);if
(if (and
(setq PNT1 (getpoint "\nPick Start of Pipe: "))
(setq PNT2 (getpoint PNT1 "\nPick End of Pipe: "))
(setq D (getdist "\nEnter Pipe Width: ")) ;In INCHES IE 24", 30", 42" SO ON
);and
(progn
(if (tblsearch "layer" my_layer)
(vl-cmdf "_.layer" "_t" my_layer "_m" my_layer "_c" my_color my_layer "_lt" my_ltype my_layer "")
(vl-cmdf "_.layer" "_m" my_layer "_c" my_color my_layer "_lt" my_ltype my_layer "")
);if
(setq D2 (/ D 12))
(setq D D2)
(while Pnt2
(setq HD (/ D 2))
(setq A (angle PNT1 PNT2))
(vl-cmdf "_.pline" "non" PNT1 "non" PNT2 "")
(setq ET (entlast))
(setq L1 (polar pnt1 (- a (dtr 90)) HD))
(setq L2 (polar pnt2 (- a (dtr 90)) HD))
(setq L3 (polar pnt1 (+ a (dtr 90)) HD))
(setq L4 (polar pnt2 (+ a (dtr 90)) HD))
(vl-cmdf "_.line" "non" L1 "non" L2 "" "line" "non" L3 "non" L4 "")
(vl-cmdf "_.change" ET "" "_p" "_lt" my_ltype_mid "") ;change linetype to suit
(vl-cmdf "_.pedit" ET "_w" D "")
(setq PNT1 PNT2)
(setq PNT2 (getpoint PNT1 "\nNext Point: <Return or Enter to Quit>: "))
);while
);progn
);if
(setvar "orthomode" OTM)
(setvar "clayer" c_layer)
(princ)
);defun

 

Alan thx for the code... using SSD, the linetype is drawn as continuous. I changed "CES.lin" to nil first but linetype didn't get drawn as HIDDEN2, only continuous. (layer popdown indicates that HIDDEN2 was intended).

FYI, PSD function is fine.

TIA, Steve

  • Like 1
Posted
What do you need to change to get your lisp to work with metric units (i.e. width 0.5m instead of 24 inches etc) and not imperial alanjt? I tried changing the lines

 

(setq D2 (/ D 12))

 

to just

(setq D2 (D)

althoguh this obviously didn't work.

As a quick fix, try (setq D2 D).

  • Like 1
Posted
Alan thx for the code... using SSD, the linetype is drawn as continuous. I changed "CES.lin" to nil first but linetype didn't get drawn as HIDDEN2, only continuous. (layer popdown indicates that HIDDEN2 was intended).

FYI, PSD function is fine.

TIA, Steve

Odd. Too be honest, I haven't looked at this routine since I modified Tim Wilson's original code to work for us. I've only actually used it a handful of times since a week after I wrote it we through Civil 3D training and switched over.

 

I'll look at it when I have a minute and see what the problem is.

Posted
Odd. Too be honest, I haven't looked at this routine since I modified Tim Wilson's original code to work for us. I've only actually used it a handful of times since a week after I wrote it we through Civil 3D training and switched over.

 

I'll look at it when I have a minute and see what the problem is.

 

Alan, my bad... I had setting set wrong in Acad.. should be set to bylayer.... all is ok.

thx Steve SSD is cool as posted.

Posted

Had a quick look, Steve. It's odd that it doesn't work. I set the linetype file to nil and it worked fine.

Two possibles:

1. Instead of leaving it nil, put in "acad.lin" for the file.

2. Make sure your CELTYPE system variable is actually set to ByLayer and not Continuous.

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