Jump to content

Extrude


kulfi

Recommended Posts

I have attached a 3dpolyline drawing coming from Utility Design i want to extrude this along its path and make it a 3d solid Pipe, Please let me know or if i can get the code is better

 

defun c:3DS()

(Setq Ss_Set (ssget "X" '((0 . "Polyline"))))

(setq Ss_Length (sslength Ss_Set))

(setq count 0)

(repeat Ss_Length

(setq Ent (ssname Ss_Set count))

(setq Ent_Data (entget Ent))

;(setq U1 (CDR (ASSOC 10 Ent_DATA))); i have the problem here how can i get the start Point

;(setq U2 (CDR (ASSOC 11 Ent_DATA))); i have the problem here how can i get the End Point

 

(COMMAND "CLAYER" P-LAYER)

(COMMAND "UCS" "W")

(SETQ SNAP1 (GETVAR "OSMODE"))

(SETQ APERTURE-1 (GETVAR "APERTURE"))

(COMMAND "OSMODE" 5)

(COMMAND "APERTURE" 4)

(initget 1)

(setq U1 (CDR (ASSOC 10 Ent_Data)))

;(setq u1 (getpoint "\nSelect From: ")

(initget 1)

(setq U2 (CDR (ASSOC 11 Ent_Data)))

;(setq u2 (getpoint "\nSelect To: ")

(initget 7)

(setq circ_dia (getreal "\nCicle diameter: "))

(COMMAND "UCS" "ZAXIS" U1 U2)

(setq u3 (TRANS U1 0 1))

(COMMAND "CIRCLE" U3 "D" circ_dia)

(setq ent (entlast))

;(command "erase" ent )

(COMMAND "UCS" "W")

(command "extrude" ent "" U1 U2 "")

(COMMAND "CLAYER" "0")

(COMMAND "OSMODE" SNAP1)

(COMMAND "APERTURE" APERTURE-1)

(COMMAND "UCS" "W")

(PRINC)

(setq count (+ 1 count))

)

 

 

 

 

Thanks

Extrude.dwg

Link to comment
Share on other sites

Were you aware that someone already wrote separate lisp programs to extrude both pipe (solid) and tube? Look for the routines XPIPE.lsp and XTUBE.lsp by former member ASMI.

Link to comment
Share on other sites

I've modified your code... HTH, M.R.

 

(defun c:3DSWEEP ( / getvertices SNAP1 APERTURE-1 DELO Ss_Set Ss_Length count circ_dia Ent Ent_Ptlst U1 U2 U3 ci )

 (defun getvertices ( pl / unique fl e p1 p2 plst )

   (vl-load-com)

   (defun unique ( l f )
     (if l
       (cons (car l) (unique (vl-remove-if '(lambda ( x ) (equal x (car l) f)) (cdr l)) f))
     )
   )

   (if (eq (cdr (assoc 100 (reverse (entget pl)))) "AcDb2dPolyline")
     (progn
       (command "_.convertpoly" "_L" pl "")
       (setq fl t)
     )
   )
   (setq e (entlast))
   (if (entnext e)
     (while (not (eq (cdr (assoc 0 (entget (setq e (entnext e))))) "SEQEND")))
   )
   (vla-explode (vlax-ename->vla-object pl))
   (while (setq e (entnext e))
     (setq p1 (vlax-curve-getstartpoint e))
     (setq p2 (vlax-curve-getendpoint e))
     (setq plst (cons p1 plst))
     (setq plst (cons p2 plst))
     (entdel e)
   )
   (if fl (command "_.convertpoly" "_H" pl ""))
   (setq plst (reverse plst))
   (unique plst 1e-3)
 )

 (setq SNAP1 (getvar "OSMODE"))
 (setq APERTURE-1 (getvar "APERTURE"))
 (setq DELO (getvar "DELOBJ"))
 (setvar "OSMODE" 0)
 (setvar "APERTURE" 4)
 (setvar "DELOBJ" 1)
 (prompt "\nSelect POLYLINE(s) for sweep processing")
 (Setq Ss_Set (ssget '((0 . "*POLYLINE"))))
 (setq Ss_Length (sslength Ss_Set))
 (setq count 0)
 (prompt "\nCicle diameter <") (princ (* (getvar "CIRCLERAD") 2.0)) (prompt "> : ")
 (initget 6)
 (setq circ_dia (getdist))
 (if (eq circ_dia nil) 
   (setq circ_dia (* (getvar "CIRCLERAD") 2.0))
 )
 (COMMAND "_.UCS" "_W")
 (repeat Ss_Length
   (setq Ent (ssname Ss_Set count))
   (setq Ent_Ptlst (getvertices Ent))
   (setq U1 (car Ent_Ptlst))
   (setq U2 (cadr Ent_Ptlst))
   (if (tblsearch "LAYER" "P-LAYER")
     (setvar "CLAYER" "P-LAYER")
   )
   (COMMAND "_.UCS" "_ZAXIS" U1 U2)
   (setq U3 (TRANS U1 0 1))
   (COMMAND "_.CIRCLE" U3 "D" circ_dia)
   (setq ci (entlast))
   (COMMAND "_.UCS" "_P")
   (COMMAND "_.EXTRUDE" ci "" "_P" Ent)
;;;;(entdel Ent) ;;;; => if you want to keep original 3dpolyline paths, just uncomment this line ;;;;
   (setq count (1+ count))
 )
 (setvar "CLAYER" "0")
 (setvar "OSMODE" SNAP1)
 (setvar "APERTURE" APERTURE-1)
 (setvar "DELOBJ" DELO)
 (COMMAND "_.UCS" "_P")
 (PRINC)
)

Edited by marko_ribar
Link to comment
Share on other sites

Now with connection to the previous problem where we had a 3dpolyline to convert to 3d solid now if i have a square or rectange object and i want to extrude to the same path how will i do that.

thanks

Link to comment
Share on other sites

Now with connection to the previous problem where we had a 3dpolyline to convert to 3d solid now if i have a square or rectange object and i want to extrude to the same path how will i do that.

thanks

 

On my machine 3DSWEEP.lsp works and for squares or rectangles... Have you checked this?

Link to comment
Share on other sites

Sorry, I thought you were asking for square, rectangle as path and not shape for extrude along path... Have you tried original SWEEP Command... It's also simple but powerful, just draw shape you wish, pick desired base point and then at the end select sweeping path along which sweep operation should be performed...

Link to comment
Share on other sites

For drawing a rectangle shape or square shape I should have automated process like pipe before if that is there it is more feasible.

thanks

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