Author Topic: Turn something ito a polyline  (Read 2408 times)

0 Members and 1 Guest are viewing this topic.

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Turn something ito a polyline
« on: November 03, 2008, 08:53:30 AM »
Hi,

===
dJE

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: Turn something ito a polyline
« Reply #1 on: November 03, 2008, 09:01:51 AM »
(OK, that was weird)

  I'm trying to select an object and turn it into polyline, and then select that object (now a polyline) automatically for use in a JOIN command.

  I'v tried using
Code: [Select]
(command "PEDIT" ent "YES" "" "")) along with a suitable test for being a polyline, but this causes trouble with selecting the object to move on.

using a variable only works if it's already a polyline, "LAST" only works if it was the last object created, and JOIN doesn't support PREVIOUS.

Any ideas?

DJE
===
dJE

VVA

  • Newt
  • Posts: 166
Re: Turn something ito a polyline
« Reply #2 on: November 21, 2008, 10:27:45 AM »
Use Region and Subtract
Code: [Select]
(defun C:OTK ( / blk pt Lpt pline otv L H *error* nab)
  (defun *error* (msg)(princ msg)
(if (and blk (entget blk)) (entdel blk))(princ))
(vl-load-com)
(setvar "cmdecho" 0)(setvar "expert" 5)
(setq pline (car (entsel "\nSelect polyline: ")))
(setq Lpt t pt (getvar "LASTPOINT"))
(while (and pline Lpt)
 (initget 7 )(setq L (getdist "\nLength of an aperture: "))
 (initget 7 )(setq H (getdist "\nHeight of an aperture: "))
 (VL-CMDF "_.Rectang" "0,0" (list L H))
 (VL-CMDF "_.-block" "TMPBLK" "0,0" "_L" "")
 (VL-CMDF "_-INSERT" "TMPBLK" "0,0" "" "" "")
 (setq blk (entlast))
 (princ "\n Insert an aperture (ENTER-exit): ")
 (setq pt (getvar "LASTPOINT"))
 (vl-cmdf "_.CHANGE" blk "" "" pause "")
 (setq Lpt (getvar "LASTPOINT"))
 (if (equal Lpt pt 0.000001)
 (progn (entdel blk)(setq Lpt nil))
 (progn
  (vl-cmdf "_.Explode" blk)
  (setq otv (entlast))
  (if (not(vl-catch-all-error-p
    (vl-catch-all-apply 'vlax-safearray->list (list (vlax-variant-value
    (vla-intersectwith (vlax-ename->vla-object otv) (vlax-ename->vla-object pline) acextendnone))))))
  (progn ;_ пересекаются
    (vl-cmdf "_.Region" pline "")(setq pline (entlast))
    (vl-cmdf "_.Region" otv "")(setq otv (entlast))
    (vl-cmdf "_subtract" pline "" otv "")
    (setq otv (entlast) nab (ssadd))
    (foreach item (vlax-invoke (vlax-ename->vla-object otv) 'Explode)
      (ssadd (vlax-vla-object->ename item) nab))
    (if (and (getvar "PEDITACCEPT") (= (getvar "PEDITACCEPT") 1))
    (vl-cmdf "_pedit" "_Multiple" nab "" "_Join" 0 "")
    (vl-cmdf "_pedit" "_Multiple" nab "" "_Y" "_Join" 0 ""))
    (setq pline (entlast) nab nil)
    (entdel otv)
    )
) ;_ if
(setq pt (getvar "LASTPOINT"))
)
)
)
(princ)
)

cadmoogle

  • Guest
Re: Turn something ito a polyline
« Reply #3 on: November 21, 2008, 10:31:11 AM »
Cool, but how did you do that gif?

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: Turn something ito a polyline
« Reply #4 on: November 21, 2008, 01:26:39 PM »

"PEDIT" "Multiple" does support "Previous".
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

cadmoogle

  • Guest
Re: Turn something ito a polyline
« Reply #5 on: November 21, 2008, 03:43:23 PM »
Set this as a button.
Code: [Select]
^C^C_peditaccept;1;_select;p;;_Pedit;m;p;;_j;0;;

1. Select objects
2. Click button that contains this macro
3. You get joined polylines

I select the lines I wish to convert and this will then join all the ones I have had selected.

This was one of my first button macros :)

I hope it helps.

Daniel

**Edit below**

If you wish to join a complete layer use this code.

Code: [Select]
;;Join polyline by layer
;;by cadmoogle - 2008
(Defun C:LJ (/ ss) ;Select layer, join all objects as a polyline.
  (defun *error* (msg)
  (setvar "QAFLAGS" 0)
  (princ)
)
(command "undo" "begin")
(command "QAFLAGS" "1")
(setq a (entget (car (entsel "Select object: "))))
(setq ss (ssget "x" (list (cons 8 (cdr (assoc 8 a))))))
(command "peditaccept" "1")
(command "_select" "p" "")
(command "_pedit" "m" "p" "" "_j" "0" "")
(command "QAFLAGS" "0")
(command "undo" "end")
(princ "\nThe layer has been joined as a polyline.")
(princ))


(OK, that was weird)

  I'm trying to select an object and turn it into polyline, and then select that object (now a polyline) automatically for use in a JOIN command.

  I'v tried using
Code: [Select]
(command "PEDIT" ent "YES" "" "")) along with a suitable test for being a polyline, but this causes trouble with selecting the object to move on.

using a variable only works if it's already a polyline, "LAST" only works if it was the last object created, and JOIN doesn't support PREVIOUS.

Any ideas?

DJE
« Last Edit: November 21, 2008, 11:59:51 PM by cadmoogle »

VVA

  • Newt
  • Posts: 166
Re: Turn something ito a polyline
« Reply #6 on: November 24, 2008, 02:24:38 AM »
Cool, but how did you do that gif?
Camtasia Studio 4.
For a free program like camtasia, look for camstudio in sourceforge.

cadmoogle

  • Guest
Re: Turn something ito a polyline
« Reply #7 on: November 24, 2008, 10:40:36 AM »
Cool thanks for the information. I love SF!