+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Forum Newbie
    Using
    not specified
    Join Date
    Mar 2006
    Location
    Monrovia, Liberia
    Posts
    6

    Default "Explode" 3D object into flat cutting pattern shap

    Registered forum members do not see this ad.

    This has probably been answered here before, but I can't find it!

    I have a 3D object (that I've created in Autocad 2004), fairly boxy in cross-section but some surfaces have simple curves in them. I am going to build this item out of flat sheet stock cut and bent into shape. How do I take a 3D object in CAD and "explode" it into the flat patterns I need (one for each face).

    In other words, how do you make a copy of each face of a 3D object, then "iron" it flat?

  2. #2
    Senior Member
    Using
    not specified
    Join Date
    Mar 2005
    Posts
    208

    Default

    I do something similar when designing patterns for custom fabric shelters, usually oil rig covers etc.

    Try to break down the 3d shape into triangles. Then pick the distances between points (list line lengths) and use those distances to draw triangles in a 2d plane.

    For curved shapes, use the length of the curved line to make the triangle. Complex curves can start getting ugly though.

    There is probably a way to do it, with a Surface, but I find that this is a quick & easy way to do it. For fabric patterns anyway.
    If there is anything the nonconformist hates worse than a conformist,
    it's another nonconformist who doesn't conform
    to the prevailing standard of nonconformity.

  3. #3
    Senior Member
    Using
    not specified
    Join Date
    Oct 2005
    Location
    UK
    Posts
    156

    Default

    Download pattern.lsp from:

    http://www.davidbethel.com/lisp/
    Aled Taylor
    (File size is someone else's problem)

  4. #4
    Forum Newbie
    Using
    not specified
    Join Date
    Mar 2006
    Location
    Monrovia, Liberia
    Posts
    6

    Default Difficulties

    Aled,

    For the life of me I can't see "pattern.lsp" on the site you linked to. . . dunno if I'm just blind or if the file was removed!

    It would be nice if it was as easy as running a LISP routine, though!

  5. #5
    Senior Member
    Using
    not specified
    Join Date
    Oct 2005
    Location
    UK
    Posts
    156

    Default

    I must have got if from somewhere else.

    Here is it anyway.

    Code:
    ;=======================================================================
    ;   Pattern.Lsp                                 May 11, 1996
    ;   Make A 3DFace Pattern And Outline From A Rulesurf Polyline
    ;================== Start Program ======================================
    (princ "\nFabricated Designs, Inc.\nLoading Pattern v1.7   ")
    (setq Pattern nil lsp_flie "Pattern")
    
    ;++++++++++++++++++ Macros +++++++++++++++++++++++++++++++++++++++++++++
    (defun PDot ()(princ "."))
    (defun RtoA (r) (/ (* r 180.0) pi))
    (defun GetVal (n e) (cdr (assoc n e)))
    (defun Sq (n) (* n n))
    (defun Beep (/ f)
     (and (wcmatch (getvar "PLATFORM") "*DOS*")
          (setq f (open "con" "w"))
          (write-char '7 f)
          (close f)))
    (defun Warn (w) (beep)
                    (princ (strcat "\nWarning !: " w))
                    (prin1))
    (defun Err (e) (beep)
                   (princ (strcat "\nError: " e))
                   (quit))
    
    (PDot);++++++++++++ Set Modes & Error ++++++++++++++++++++++++++++++++++
     (defun pa_smd ()
      (command "_.UNDO" "_GROUP")
      (setq m_v nil m_n nil
            m_l (list "CMDECHO" "BLIPMODE" "HIGHLIGHT")
            m_s (list 0 0 1)
         olderr *error*
        *error* (lambda (s)
         (cond ((= s "Function cancelled"))
               ((= s "quit / exit abort"))
               ((princ (strcat "\nError: " s))))
         (pa_rmd)))
      (foreach x m_l (setq m_v (cons (getvar x) m_v)
                           m_n (cons x m_n)))
      (mapcar 'setvar m_l m_s)
      (princ (strcat (getvar "PLATFORM") " Release " (ver)
             "\nPattern Generator   ")))
    
    (PDot);++++++++++++ Return Modes & Error +++++++++++++++++++++++++++++++
     (defun pa_rmd ()
      (command "_.UNDO" "_END")
      (setq *error* olderr)
      (mapcar 'setvar m_n m_v)
      (prin1))
    
    (PDot);++++++++++++ Make Layer Current International +++++++++++++++++++
    (defun set_layer (lay_name / lay_list lay_flag)
      (if (not (tblsearch "LAYER" lay_name))
          (command "_.LAYER" "_MAKE" lay_name "")
          (progn
           (setq lay_list (tblsearch "LAYER" lay_name)
                 lay_flag (cdr (assoc 70 lay_list)))
           (if (= (logand lay_flag  1)  1)
               (command "_.LAYER" "_THAW" lay_name ""))
           (if (minusp (cdr (assoc 62 lay_list)))
               (command "_.LAYER" "_ON" lay_name ""))
           (if (= (logand lay_flag  4)  4)
               (command "_.LAYER" "_UNLOCK" lay_name ""))
           (and (= (logand lay_flag 16) 16)
                (princ "\nCannot Set To XRef Dependent Layer")
                (quit))
           (command "_.LAYER" "_SET" lay_name ""))))
    
    (PDot);++++++++++++ Draw Patterns ++++++++++++++++++++++++++++++++++++++
    (defun drpat (no ne / fp1 fp2 fp3 fp4 s1 s2 s3 s4 cs1 cs2 cs3 cs4 cs5 cs6
                 sn1 sn2 sn3 sn4 sn5 sn6 ang yt y3 p1 p2 p3 p4 ldef an4 an5)
     (setq fdef (entget ne)
            fp1 (GetVal 10 fdef) fp2 (GetVal 11 fdef)
            fp3 (GetVal 12 fdef) fp4 (GetVal 13 fdef)
             s1 (distance fp1 fp2) s2 (distance fp2 fp3)
             s3 (distance fp1 fp3) s4 (distance fp1 fp2)
             s5 (distance fp2 fp4) s6 (distance fp4 fp1))
      (setq s1c (if (zerop s1) 1.0 s1))
      (setq s2c (if (zerop s2) 1.0 s2))
      (setq s3c (if (zerop s3) 1.0 s3))
      (setq s4c (if (zerop s4) 1.0 s4))
      (setq s5c (if (zerop s5) 1.0 s5))
      (setq s6c (if (zerop s6) 1.0 s6))
      (setq cs1 (/ (- (+ (Sq s1) (Sq s3)) (Sq s2)) (* 2 s1 s3))
            cs2 (/ (- (+ (Sq s2) (Sq s1)) (Sq s3)) (* 2 s1 s2))
            cs3 (/ (- (+ (Sq s3) (Sq s2)) (Sq s1)) (* 2 s2 s3))
            cs4 (/ (- (+ (Sq s4) (Sq s6)) (Sq s5)) (* 2 s4 s6))
            cs5 (/ (- (+ (Sq s5) (Sq s4)) (Sq s6)) (* 2 s4 s5))
            cs6 (/ (- (+ (Sq s6) (Sq s5)) (Sq s4)) (* 2 s5 s6))
            sn1 (sqrt (- 1.0 (Sq cs1)))
            sn2 (sqrt (- 1.0 (Sq cs2)))
            sn3 (sqrt (- 1.0 (Sq cs3)))
            sn4 (sqrt (- 1.0 (Sq cs4)))
            sn5 (sqrt (- 1.0 (Sq cs5)))
            sn6 (sqrt (- 1.0 (Sq cs6)))
            ang (angle no (list (+ (car no) (* s1 cs3)) (+ (cadr no) (* s1 sn3))))
             yt (polar no s1 ang)
             y3 (cadr (polar yt s1 (* -1.0 ang)))
             p1 (list (+ (car no) (* s3 cs1)) (+ (cadr no) (* s3 sn1)))
             p2 (list (+ (car no) (* s2 cs2)) (+ (cadr no) (* s2 sn2)))
             p3 (list (+ (car no) (* s1 cs3)) y3)
             p4 (list (+ (car no) (* s6 cs4)) (+ (cadr no) (* s6 sn4))))
    (command "_.3DFACE" no p3 p1 p4 "")
    (setq ldef (entget (entlast)))
    (setq an4 (rtoa (angle (GetVal 10 ldef) (GetVal 13 ldef)))
          an5 (rtoa (angle rp11 rp12)))
    (if (= i (1- sl))
        (command "_.ROTATE" (entlast) "" no fa)
        (command "_.ROTATE" (entlast) "" no (- an5 an4)))
    (setq rdef (entget (entlast)))
    (setq rp10 (GetVal 10 rdef)
          rp11 (GetVal 11 rdef)
          rp12 (GetVal 12 rdef)
          rp13 (GetVal 13 rdef))
    (redraw (entlast)))
    
    (PDot);++++++++++++ Draw Outlines ++++++++++++++++++++++++++++++++++++++
    (defun drout ()
      (initget "Yes No")
      (if (= "No"  (getkword "\nForm PolyLine Outline <Y>:... "))
          (princ)
          (progn
      (setq nlay
       (getstring
        (strcat "\nEnter Layer For Outline <" (getvar "CLayer") ">:  ")))
      (set_layer nlay)
      (princ "\nForming PLine Outlines...   ")
      (command "_.PLINE" (car pl2) (cadr pl2) "")
      (command "_.PLINE" (car pl4) (cadr pl4) "")
      (setq i (1- (length pl1)))
      (command "_.PLINE" (nth i pl1) "_Width" 0)
      (setq i (1- i))
      (while (>= i 0)
             (command (nth i pl1))
             (setq i (1- i)))
      (command "")
      (setq i (1- (length pl3)))
      (command "_.PLINE" (nth i pl3) "_Width" 0)
      (setq i (1- i))
      (while (>= i 0)
             (command (nth i pl3))
             (setq i (1- i)))
      (command ""))))
    
    (PDot);++++++++++++ Get Entity Name ++++++++++++++++++++++++++++++++++++
    (defun GetOne (/ st os)
     (setq os (getvar "SNAPMODE") s nil)
     (setvar "SNAPMODE" 0)
     (while (not st)
            (setq st (ssget)))
     (while (> (sslength st) 1)
            (setq st nil)
            (princ "\nOnly 1 At A Time Please\n")
            (while (not st)
                   (setq st (ssget))))
     (setvar "SNAPMODE" os)
     (setq s (ssname st 0)))
    
    (PDot);++++++++++++ Get Polyline Info ++++++++++++++++++++++++++++++++++
    (defun GetPl ()
      (GetOne)
      (setq pdef (entget s))
      (if (or (/= (GetVal 0 pdef) "POLYLINE")
              (/= (GetVal 71 pdef) 2)
              (/= (logand (GetVal 70 pdef) 16) 16))
          (err "Not A Rulesurf Polyline"))
      (command "_.COPY" s "" (list 0 0) (list 0 0))
      (setq fe (entnext))
      (command "_.EXPLODE" (entlast))
      (setq fs (ssadd))
      (while fe
             (ssadd fe fs)
             (setq fe (entnext fe)))
      (setq sl (sslength fs)
             i (1- sl)
            sd (ssname fs i)
           ss1 (ssadd)
          temp T)
      (repeat sl
            (if (= "3DFACE" (GetVal 0 (entget sd)))
                (ssadd sd ss1))
            (setq i (1- i)
                 sd (ssname fs i))))
    
    (PDot);++++++++++++ Get Face Info ++++++++++++++++++++++++++++++++++++++
    (defun GetFc ()
      (setq flay (getstring
        (strcat "\nEnter LAyer Of 3DFaces <"clay">:   ")))
      (if (= flay "") (setq flay clay))
      (setq ss1 (ssget "X" (list (cons 0 "3DFACE") (cons 8 flay))))
      (if (not ss1)
          (err "\nNo 3DFaces Found")))
    
    (PDot);************ Main Program ***************************************
     (defun Pattern (/ m_n m_v m_s m_l olderr temp clay flay nlay fdef rdef
                       sd i fe fs s rp10 rp11 rp12 rp13 fa no ne ss1
                       pdef pl1 pl2 pl3 pl4 play s1c s2c s3c s4c s5c s6c
                       s5 s6 sl)
      (pa_smd)
      (setq clay (getvar "CLAYER"))
      (initget "Polyline Face")
      (if (= "Face" (getkword "\nFrom Polyline or Faces 
    
    :   "))
          (GetFc)
          (GetPl))
      (setq play (strcase (getstring
        (strcat "\nEnter LAyer For Pattern <"clay">:   "))))
      (if (= play "") (setq play clay))
      (if (/= clay play)
          (set_layer play))
      (setq sl (sslength ss1)
             i (1- sl)
            ne (ssname ss1 i)
          fdef (entget ne)
          rp10 (GetVal 10 fdef)
          rp11 (GetVal 11 fdef)
          rp12 (GetVal 12 fdef)
          rp13 (GetVal 13 fdef)
            fa (rtoa (angle rp10 rp11))
            no rp10)
      (command "_.ELEV" (caddr rp10) 0.0)
      (while (>= i 0)
             (drpat no ne)
             (if (= i (1- sl))
                 (setq pl4 (list rp13 rp10)
                       pl1 (list rp10)
                       pl3 (list rp13)))
             (setq i (1- i)
                  ne (ssname ss1 i)
                  no rp11
                 pl1 (cons rp10 pl1)
                 pl3 (cons rp13 pl3)))
      (setq pl2 (list rp11 rp12)
            pl1 (cons rp11 pl1)
            pl3 (cons rp12 pl3))
      (redraw)
      (drout)
      (if temp (command "_.ERASE" ss1 ""))
      (redraw)
      (pa_rmd))
    
    (PDot);************ Load Program ***************************************
     (defun C:Pattern () (Pattern))
     (if Pattern (princ "\nPattern Defined\n"))
     (prin1)
    ;|================= End Program ========================================
    Aled Taylor
    (File size is someone else's problem)

  6. #6
    Forum Newbie
    Using
    not specified
    Join Date
    Mar 2006
    Location
    Monrovia, Liberia
    Posts
    6

    Default

    Registered forum members do not see this ad.

    Thanks!

    I'll mess around with that and see if it gives me what I'm after.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts