TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: t-bear on September 21, 2004, 02:34:19 PM

Title: Rectangle, extrude in one step.....help?
Post by: t-bear on September 21, 2004, 02:34:19 PM
I've "acquired" this snippet from a larger routine and I'm trying to make it extrude along a path.
Code: [Select]
^C^C(progn (command ".rectang" pause pause) (command ".extrude" "L" "" pause "" 0))
It creates the rectangle and will extrude a given distance, but trying to extrude along a path crashes the durned thing.  Any ideas?
Title: Rectangle, extrude in one step.....help?
Post by: CAB on September 21, 2004, 03:00:46 PM
Maybe?
Code: [Select]
^C^C(progn (command ".rectang" pause pause) (command ".extrude" "L" "" "_P" pause))
Title: Rectangle, extrude in one step.....help?
Post by: Columbia on September 21, 2004, 04:01:54 PM
Try this on for size.  I know it's a little more complicated, but it works well for me at the command line.
Code: [Select]

(defun c:ext_rect (/ ent corner1 corner2)
  (if (setq corner1 (getpoint "\nPick first corner of Rectangle..."))
    (if (setq corner2 (getcorner corner1 "\nPick Second Corner of Rectangle..."))
      (if (setq ent (entsel "\nPick entity to extrude along..."))
        (progn
          (command "._pline" "_non" corner1 "w" 0 0
                          "_non" (list (car corner1) (cadr corner2))
                          "_non" corner2
                          "_non" (list (car corner2) (cadr corner1))
                          "C"
          )
          (command "._extrude" (entlast) "" "_P" (car ent))
        )
        (princ "\nNo Entity Path Picked...")
      )
      (princ "\nNo second corner picked...")
    )
    (princ "\nNo point picked...")
  )
  (princ)
)


I hope this helps, if not then you can ignore if you so choose.
Title: Rectangle, extrude in one step.....help?
Post by: t-bear on September 21, 2004, 04:35:54 PM
CAB.... Works a treat, kiddo!  Thanks.
Columbia.... that works too.  I was trying to do this as a script in a tool button like CABs, but this works too.  Just have the button call the lisp.
Now....I'm gonna *TRY* to make these two work with a circle....wish me luck, I'm so dense, I'll need all I can get. LOLOL
Title: Rectangle, extrude in one step.....help?
Post by: CAB on September 21, 2004, 05:56:37 PM
Hollar ifin you don't get it. :)
Title: Rectangle, extrude in one step.....help?
Post by: Columbia on September 22, 2004, 07:30:25 AM
T-Bear,

If you get stuck doing it yourself, have a look at this little routine.  Again, I love to use this thing, but that doesn't mean you will.
Code: [Select]

(vl-load-com)
(defun c:tube (/ end1 end2 dia ent pt ptlist dist stpt zcoord ucsorig midpt)
  (vl-cmdf "._undo" "_begin") ;; set undo marker
  (setq $_soild_dia_$ (if $_soild_dia_$ $_soild_dia_$ 6.0) ;; initialize global
        dia (getreal
               (strcat "\nEnter Tube Diameter <"
                 (vl-princ-to-string $_soild_dia_$) ">: "
               )
             )
  )
  (if (/= dia nil) (setq $_soild_dia_$ dia)) ;; use global if "ENTER" button is hit.
  (while (setq ent (entsel "\nSelect Line to Build Tube around: "))
    (if
      (and
        (setq pt  (osnap (cadr ent) "nea"))
        (setq ent (car ent))
      )
      (progn
        (cond
          ( (= (cdr (assoc 0 (entget ent))) "LINE")
            (setq
              end1 (cdr (assoc 10 (entget ent))) ;; find endpoint 1
              end2 (cdr (assoc 11 (entget ent))) ;; find endpoint 2
              dist (distance end1 end2)
            )
            (vl-cmdf "._ucs" "_zaxis" "_non" end1 "_non" end2)
            (vl-cmdf "._cylinder" "_non" (trans end1 0 1) "_d" $_soild_dia_$ dist)
            (vl-cmdf "._ucs" "_p")
          )
        )
      )
    )
  )
  (vl-cmdf "._undo" "_end")
  (princ)
)
Title: Rectangle, extrude in one step.....help?
Post by: Mark on September 22, 2004, 08:25:19 AM
Code: [Select]
(vl-cmdf "._undo" "_begin") ;; set undo marker
excellent!!  :D
Title: Rectangle, extrude in one step.....help?
Post by: SMadsen on September 22, 2004, 08:40:35 AM
Columbia, just simple curiousity to see if there's a lesson in this. Is there a reason that the EXT_RECT doesn't use the BOX command when TUBE use the CYLINDER command?
Title: Rectangle, extrude in one step.....help?
Post by: t-bear on September 22, 2004, 09:38:49 AM
OK...Ihave this
Code: [Select]
^C^C(progn (command ".circle" pause pause) (command ".extrude" "L" "" "_P" pause)) and it works...but....I need it to default to diameter.  I know I need a "d" in there *somewhere* but wherever I put it, it crashes.  Like I said, I'm NO lisper! Sorry to be so dense...... I realize this is basics.
Title: Rectangle, extrude in one step.....help?
Post by: CAB on September 22, 2004, 09:44:58 AM
Code: [Select]
^C^C(progn (command ".circle" pause "D" pause) (command ".extrude" "L" "" "_P" pause))
Title: Rectangle, extrude in one step.....help?
Post by: t-bear on September 22, 2004, 10:06:00 AM
THAT's where it goes!!  I had the durned thang ev'r whar BUT!  With and without the ""....DUH!
Thanks a ton CAB, works sweeeeet!
Title: Rectangle, extrude in one step.....help?
Post by: Columbia on September 22, 2004, 10:17:55 AM
Stig,
no real lesson.  T-bear just wanted to extrude along a path.  If you're just using a single segement for the path, then BOX will work great.  But if you've got multiple segments (i.e. a 3DPOLY entity) then you need to use extrude along a path.  The TUBE command does NOT take into account a multisegmented entity.  In fact it only uses LINES.

I only posted it as a sort of guide, or here's what else you could do, type of thing.
Title: Rectangle, extrude in one step.....help?
Post by: SMadsen on September 22, 2004, 01:03:39 PM
Quote from: Columbia
T-bear just wanted to extrude along a path.
Ah of course. I missed that part. Umm .. it was only part of the topic title  :roll:

Thanks Columbia
Title: Rectangle, extrude in one step.....help?
Post by: AVCAD on September 27, 2004, 10:22:41 AM
just use the cube.....BOX....command.
Title: Re: Rectangle, extrude in one step.....help?
Post by: SpeedCAD on September 27, 2004, 12:32:53 PM
Quote from: t-bear
I've "acquired" this snippet from a larger routine and I'm trying to make it extrude along a path.
Code: [Select]
^C^C(progn (command ".rectang" pause pause) (command ".extrude" "L" "" pause "" 0))
It creates the rectangle and will extrude a given distance, but trying to extrude along a path crashes the durned thing.  Any ideas?


Hi...

You test this:
Code: [Select]
^C^C_.rectangle;\\_.extrude;_l;;_p;\