Jump to content

Creating single line duct work!


cadmando2

Recommended Posts

I'm working on a big project and to cut down on drawing I'm looking for away to create single line duct work and flex duct.

I had a wpipe.lsp but how do you set i to create a single line?

I tried to set it to 0 but the wpipe.lsp didn't like it. i need a to create flex duct.

But I have a lot of demolition to do.

what we do is offset the duct on each side of the duct and create pline so that the full lenth of the duct show two ducts one inside the other so I can hatch it to show the demo.then I remove the outside out line of the duct

any idea how I can cut down on the steps to create a hatch around the duct that is being demo?

 

here what the steps look like.

1 duct (Small).jpg

2 offsetduct (Small).jpg

3 hatchduct (Small).jpg

4 hatchduct (Small).jpg

Link to comment
Share on other sites

A simple way would to be to use the MEASURE command with a BLOCK that contains a presized X line pattern on the LINE,ARC,*PLINEs of the duct run.

Command: MEASURE

Select object to measure:
<Segment length>/Block: _B
Block name to insert: DEMO

Align block with object? <Y>

Segment length: 1.5

-David

-DEMO.JPG

-DEMO.DWG

Link to comment
Share on other sites

Can this measure command be writen in a script?

I tryed but I seen to remember if a script will allow you to select and resume the script?

:?

I tried it and it works great, but it would be great if I could put it in a script or lisp routine.

the reason is to set the right layer!

But this measure command will on work on a flex duct! How could I get that part to work.

Here is one of the project i'm working on. all the Magenta color duct will be removed and the flex duct is still in debate about removing it.

DEMO A FLEX DUCT (Small).jpg

Link to comment
Share on other sites

For example, a very simple LISP to accomplish something like what David has achieved, but with a single click:

 

(defun c:duct (/ *error* Cmd cEnt)
 (defun *error* (msg) (setvar "CMDECHO" Cmd) (princ))
 (setq Cmd (getvar "CMDECHO")) (setvar "CMDECHO" 0)
 (if (and (setq cEnt (car (entsel "\nSelect Duct Centerline > ")))
      (tblsearch "BLOCK" "DEMO"))
   (progn
     (command "_measure" cEnt "_B" "DEMO" "_Y" "1.5"))
   (princ "\n<!> No Object Selected or Block not Found <!>"))
 (setvar "CMDECHO" Cmd)
 (princ))

Link to comment
Share on other sites

Or, to apply to all LWPOLYLINES in the drawing space:

 

(defun c:duct (/ *error* Cmd ss)
 (vl-load-com)
 (defun *error* (msg) (setvar "CMDECHO" Cmd) (princ))
 (setq Cmd (getvar "CMDECHO")) (setvar "CMDECHO" 0)
 (if (and (setq ss (ssget "X" (list (cons 0 "LWPOLYLINE")
            (if (getvar "CTAB")(cons 410 (getvar "CTAB"))
              (cons 67 (- 1 (getvar "TILEMODE")))))))
          (tblsearch "BLOCK" "DEMO"))
   (progn
     (mapcar '(lambda (x) (command "_measure" x "_B" "DEMO" "_Y" "1.5"))
         (mapcar 'cadr (ssnamex ss))))
   (princ "\n<!> No Object Selected or Block not Found <!>"))
 (setvar "CMDECHO" Cmd)
 (princ))

Duct Example.zip

Link to comment
Share on other sites

Thank's Lee.

You seem to always come threw for me.

I'm final got my self a book from the library about customing "Lisp"

But it seem that I never have time at work on reading and playing with lisp routines on CAD 2008. If everyone would leave me alone I could get my work done and have more time learning "AutoLisp".

But one asking me about CAD or having troubles in CAD. and I'm not getting paid as a CAD Manager.

But I'm greatfull that I'm still working, but I'm always needed Lisp routine to make are job easyer.

Heres one. I got this single in duct Lisp routine, but It is creating double lines and I would like the opption to change the single line duct into a pline? that way the Demo "measure" lisp you created would work!

I just trying to cut some corrners scents I'm running out of time getting my work done..

 

Code it use:

; Draws continuous pipe (or duct) of any size

; with user defined inner bend radius (default = 0.0)

(defun c:bd (/ d1 d p1 p2 p3 rd1 rd2 lu1 lu2 u1 u2 u3 u5 erd elu erd2

elu2 ofr)

(setq oerr *error*)

(defun *error* (msg)

(setvar "filletrad" ofr)

(setvar "osmode" osn)

(princ

"Function cancelled by user, or radius is too large "

)

(setq *error* oerr)

(command)

(princ)

)

(setq osn (getvar "osmode"))

(setq ofr (getvar "filletrad"))

(setvar "cmdecho" 0)

(if (= d2 nil)

(setq d2 1.0)

)

(princ "\n Pipe diameter / duct width

(princ d2)

(princ " >?:")

(setq d1 (getdist))

(if (= d1 nil)

(setq d1 d2)

)

(setq d2 d1)

(if (= r1 nil)

(setq r1 0.0)

)

(princ "\n Inner bend radius

(princ r1)

(princ " >?:")

(setq r (getdist))

(if (= r nil)

(setq r r1)

)

(setq r1 r)

(setq d (/ d1 2))

(setq p1 (getpoint "\n Start point: "))

(setq p2 (getpoint p1 "\n Next point: "))

(setq u1 (angle p1 p2))

(setq rd1 (polar p1 (- u1 (* pi 0.5)) d)) ; rd = right

(setq rd2 (polar rd1 u1 (distance p1 p2)))

(setq lu1 (polar p1 (+ u1 (* pi 0.5)) d)) ; lu = left

(setq lu2 (polar lu1 u1 (distance p1 p2)))

(setvar "osmode" 0)

(command "line" rd1 lu1 "")

(command "line" rd1 rd2 "")

(setq erd (entlast))

(command "line" lu1 lu2 "")

(setq elu (entlast))

(setvar "osmode" osn)

(setq p3 (getpoint p2 "\n Next"))

(setvar "osmode" 0)

(setq u2 (angle p2 p3))

(setq u5 (+ (- pi u1) u2))

(if (> u5 (* pi 2))

(setq u5 (- u5 (* pi 2)))

)

(if (

(setq u5 (+ (* pi 2) u5))

)

(while p3

(setq p1 p2)

(setq p2 p3)

(setq u1 (angle p1 p2))

(setq rd1 (polar p1 (- u1 (* pi 0.5)) d)) ; rd = right/down

(setq rd2 (polar rd1 u1 (distance p1 p2)))

(setq lu1 (polar p1 (+ u1 (* pi 0.5)) d)) ; lu = left/up

(setq lu2 (polar lu1 u1 (distance p1 p2)))

(command "line" rd1 rd2 "")

(setq erd2 (entlast))

(command "line" lu1 lu2 "")

(setq elu2 (entlast))

(if (

(progn

(setvar "filletrad" r)

(command "fillet" erd erd2)

(setvar "filletrad" (+ d1 r))

(command "fillet" elu elu2)

)

)

(if (> u5 pi)

(progn

(setvar "filletrad" (+ d1 r))

(command "fillet" erd erd2)

(setvar "filletrad" r)

(command "fillet" elu elu2)

)

)

(setq erd erd2)

(setq elu elu2)

(setvar "osmode" osn)

(setq p3 (getpoint p2 "\n Next:"))

(setvar "osmode" 0)

(if (= p3 nil)

()

(setq u2 (angle p2 p3))

)

(setq u5 (+ (- pi u1) u2))

(if (> u5 (* pi 2))

(setq u5 (- u5 (* pi 2)))

)

(if (

(setq u5 (+ (* pi 2) u5))

)

 

)

 

(command "line" rd2 lu2 "")

(setvar "osmode" osn)

(setvar "filletrad" ofr)

(princ)

)

 

thanks again

Curt:)

Link to comment
Share on other sites

No probs Curt, I shall see what I can do :)

 

By the way, is there a certain layer you would like the duct to be on? and would you like to keep the polyline centerline?

Link to comment
Share on other sites

Perhaps something like this?

 

 


(defun c:bd  (/ *error* vlst ovar)
 (defun *error*  (msg)
   (if    ovar (mapcar 'setvar vlst ovar))
   (princ (strcat "\nError: " (strcase msg)))
   (princ))
 (setq    vlst '("CMDECHO" "CLAYER" "FILLETRAD")
   ovar (mapcar 'getvar vlst))
 (setvar "CMDECHO" 0) (setvar "FILLETRAD" 2.0)
 (if (or (tblsearch "BLOCK" "Demo")
     (and (findfile "Demo.dwg")
          (command "_.INSERT" "Demo") (command)))
   (progn
     (if (not (tblsearch "LAYER" "Duct"))
   (command "-layer" "M" "Duct" "_C" "6" "Duct" "")
   (setvar "CLAYER" "Duct"))
     (princ "\nConstruct Duct Line...")
     (command "_pline")
     (while (> (getvar "CMDACTIVE") 0) (command pause))
     (command "_fillet" "_P" (entlast))
     (command "_measure" (entlast) "_B" "Demo" "Y" "1.5"))
   (princ "\n<!> Block Not Found <!>"))
 (mapcar 'setvar vlst ovar)
 (princ))

Link to comment
Share on other sites

Doesn't MEASURE require a point input? an ename doesn't work up thru A2K. Maybe the command has changed since. -David

Link to comment
Share on other sites

Doesn't MEASURE require a point input? an ename doesn't work up thru A2K. Maybe the command has changed since. -David

 

I can only think that the command has changed since then, as my posted code seems to work on ACAD '04.

Link to comment
Share on other sites

Thanks Lee.

It works Great. Tried it at home on 2004.

I did changed the Filletrad form 2" to 8" and the Segment length to 11" so the X would not over lap so much.

The Lisp routine you created in how it was writen is starting to make scents to me because I understand the operation. It is just the (/ *error* vlst ovar)

(defun *error* (msg)

(if ovar (mapcar 'setvar vlst ovar))

(princ (strcat "\nError: " (strcase msg)))

(princ))

that i'm having trouble with understanding right now.

I can tweak lisp routine and is simple like this and I can under stand it. It help to learn who to

Start writing my own.

Thanks again.

Thanks for the support of everyone and there input. It make are jobs so much easier.

:D :D

Link to comment
Share on other sites

It is just the (/ *error* vlst ovar)

(defun *error* (msg)

(if ovar (mapcar 'setvar vlst ovar))

(princ (strcat "\nError: " (strcase msg)))

(princ)) ...

 

 

Glad it works for you :)

 

As for this:

 

[size=3][font=Times New Roman] (/ *error* vlst ovar)
 (defun *error*  (msg)
   (if    ovar (mapcar 'setvar vlst ovar))
   (princ (strcat "\nError: " (strcase msg)))
   (princ)) 
[/font][/size]

 

Lets take things separately:

 

First:

 

[size=3][font=Times New Roman](/ *error* vlst ovar)[/font][/size]

Is part of the function: "defun" and all local variables should be enclosed within the brackets, after the forward slash. (Arguments for the function being placed before the forward slash - but this function takes no arguments). Look up the "defun" function in the VLIDE help and you will see what I mean.

 

Localising the variables not only helps you to keep track of the symbols you have used as variables, but also wipes any values from these symbols after the program has completed.

 

Now, onto:

 

[size=3][font=Times New Roman](defun *error*  (msg)
       (if    ovar (mapcar 'setvar vlst ovar))
       (princ (strcat "\nError: " (strcase msg)))
   (princ)) [/font][/size]

This is an error handler for the program - it takes one argument (the error message) which is returned when ACAD returns an Error. The program basically says, 'If there is an Error, return all variables to how they were, and print the error message."

 

(defun *error* (msg)  ;;   --->  Define the Error Function, but *error* then must be localised.

[size=3][font=Times New Roman]    (if    ovar (mapcar 'setvar vlst ovar))[/font][/size]  ;;  --->  If old variables have been stored, set the variables in the variable list back to their old state.

[size=3][font=Times New Roman]    (princ (strcat "\nError: " (strcase msg)))[/font][/size]  ; ---> Print the Error Message.

Hope this clarifies things a little more.

 

If you have any more questions on this, or something else, just ask.

 

Lee

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