• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual LISP, AutoLISP and General Customization

    Reply
    Active Member
    Posts: 7
    Registered: ‎01-29-2007

    Convert Ellipse segment into spline or polyline

    844 Views, 7 Replies
    05-03-2012 02:46 PM

    Hello

     

    Our customer send us drawing with ellipse segments  into.

     

    With Autocad 2008 I bought a plug-in call SplineConvert that did the job perfectly but not compatible with 2013.

    Is there any plugin that could replace that tool  ?

     

    Is there any standard ACAD command that could easily do this Job ?

    I need a way to make 2 or 3 times per week  this converting on all ellipses of large and detail 2D drawings so no time to offset in and out all those .

     

    I try also DXFOUT in R12 but all the spline are being converted into 3d  polyline making a huge files that froze my PC.

     

    I also try FLATTEN but did not see how it work , the ellipse stay an ellipse.

     

    Is there anyone with a link or a method to solve this problem ?

     

    Thank in advance !!!

    Please use plain text.
    *Expert Elite*
    Kent1Cooper
    Posts: 4,080
    Registered: ‎09-13-2004

    Re: Convert Ellipse segment into spline or polyline

    05-03-2012 04:27 PM in reply to: plap1

    plap1 wrote:

    .... 

    Is there any standard ACAD command that could easily do this Job ?

    I need a way to make 2 or 3 times per week  this converting on all ellipses of large and detail 2D drawings so no time to offset in and out all those .

    ....


    Try this [minimally tested]:

     

    (vl-load-com); if needed

    (foreach

      x

      (mapcar 'cadr (ssnamex (ssget "X" '((0 . "ELLIPSE"))))); all Ellipse objects in list

      (vla-offset (vlax-ename->vla-object x) 1); offset outward

      (entdel x); get rid of original Ellipse
      (setq x (entlast))

      (vla-offset (vlax-ename->vla-object x) -1); offset inward

      (entdel x); get rid of intermediate Spline

    )

    Kent Cooper
    Please use plain text.
    Valued Contributor
    Posts: 59
    Registered: ‎04-12-2007

    Re: Convert Ellipse segment into spline or polyline

    05-04-2012 12:33 PM in reply to: Kent1Cooper

    First of all I have to say Kent that I really like your mapcar fuction. I wouldn't have thought of using ssnamex to create a list of enames. Very cool.

    If you don't mind I would like to use that line here. If the OP (or any one else) has Express Tools loaded. Give this a try. I have tried using the follow code in AutoCAD 2013 and it worked for me. Hope that helps.

     

    (foreach x (mapcar 'cadr (ssnamex (ssget "X" '((0 . "ELLIPSE")))))
     (ACET-GEOM-ELLIPSE-TO-PLINE x)
     (entdel x)
    )

     

    Jim

     

    Please use plain text.
    Active Member
    Posts: 7
    Registered: ‎01-29-2007

    Re: Convert Ellipse segment into spline or polyline

    05-04-2012 01:06 PM in reply to: jsowinski
    Thank you for your help Before trying it I have found a routine S-E2PL onto another forum that give result that look lot alike SplineConvert . The only thing it don?t keep the original layers for the transform spline and ellipse . It put all the result on layer 0 . I don?t know lisp enough to figure what it take to keep the layer. What should be modified ? Thank again ! (defun C:smileyfrustrated:-E2PL ( / js n ent typent dxf_ent obj_vlax param_start param_end perim_obj pt_start pt_end res_track res_divid flag_ucs flag_erase last_e old_osmd old_pdmd l_pt) (setq js (ssget "_X" '((0 . "SPLINE,ELLIPSE")))) (cond (js (vl-load-com) (initget "Mesurer Diviser _Measure Divide") (if (eq (getkword "\nAction par [Mesurer/Diviser]? < Mesurer >: ") "Divide") (progn (initget 7) (setq res_divid (getint "\nNombre de division: ")) ) (progn (initget 7) (setq res_track (getdist "\nDistance de r?solution: ")) ) ) (setq old_osmd (getvar "osmode") old_pdmd (getvar "pdmode") n -1 ) (initget "Oui Non _Yes No") (if (eq (getkword "\nVoulez vous faire une projection sur le SCU courant? [Oui/Non] < Non >: ") "Yes") (setq flag_ucs nil) (setq flag_ucs T) ) (initget "Oui Non _Yes No") (if (not (eq (getkword "\nEffacer l'entit? source [Oui/Non] < Oui >: ") "No")) (setq flag_erase T) (setq flag_erase nil) ) (setvar "osmode" 0) (setvar "pdmode" 1) (setvar "cmdecho" 0) (repeat (sslength js) (setq ent (ssname js (setq n (1+ n))) obj_vlax (vlax-ename->vla-object ent) param_start (vlax-curve-getStartParam obj_vlax) param_end (vlax-curve-getEndParam obj_vlax) perim_obj (vlax-curve-getDistAtParam obj_vlax (+ param_start param_end)) pt_start (vlax-curve-getStartPoint obj_vlax) pt_end (vlax-curve-getEndPoint obj_vlax) last_e (entlast) ) (if res_divid (setq res_track (/ perim_obj res_divid))) (if flag_ucs (command "_.ucs" "_entity" ent)) (cond ((and (eq typent "SPLINE") (not (zerop (boole 1 1 (cdr (assoc 70 dxf_ent)))))) (setq l_pt '("_close")) ) ((and (eq typent "ELLIPSE") (zerop (cdr (assoc 41 dxf_ent))) (eq (cdr (assoc 42 dxf_ent)) (* 2 pi))) (setq l_pt '("_close")) ) (T (setq l_pt (cons (trans pt_end 0 1) '(""))) ) ) (command "_.measure" ent res_track) (while (and (= (cdr (assoc 0 (setq dxf_ent (entget (entlast))))) "POINT") (not (equal (entlast) last_e)) ) (setq l_pt (cons (trans (cdr (assoc 10 dxf_ent)) 0 1) l_pt)) (entdel (entlast)) ) (command "_.pline" (mapcar 'command (cons (trans pt_start 0 1) l_pt))) (if flag_ucs (command "_.ucs" "_previous")) (if flag_erase (entdel ent)) ) (setvar "osmode" old_osmd) (setvar "pdmode" old_pdmd) (setvar "cmdecho" 1) ) (T (princ "\nAucune Spline ou Ellipse trouv?e!")) ) (prin1) ) (princ "\nS-E2PL.LSP charg?. Tapez S-E2PL pour convertir SPLINE ou ELLIPSE en POLYLIGNE.") (prin1) Pierre Lapointe ing. MULTI-TAPE (M.T.I.) INC. Masking Technologies & Innovations 680 Boul.Lemire Drummondville, Qu?. J2C-7W9 T?l 888-477-4189 poste 30, Fax 819-477-4193 plapointe@mtimasking.com
    Please use plain text.
    *Expert Elite*
    Kent1Cooper
    Posts: 4,080
    Registered: ‎09-13-2004

    Re: Convert Ellipse segment into spline or polyline

    05-04-2012 01:35 PM in reply to: jsowinski

    jsowinski wrote:

    First of all I have to say Kent that I really like your mapcar fuction. I wouldn't have thought of using ssnamex to create a list of enames. Very cool.

    ....


    I can't take credit for thinking up that (mapcar)-with-(ssnamex) thing -- it was a trick that a user with the handle Some Buddy used, a couple/few years back.  I think their version was somewhat more complicated, because it was for a selection set that included user-picked objects, for which (ssnamex) returns a different assortment of information depending on how each thing got into the set.  So at first I didn't catch on to what it could do.  But when you're using (ssget "X"), the entity name is always the second element in each entry in the list (ssnamex) returns, so you can just apply (cadr) to everything and get a straightforward list of entity names.  When applicable, doing that and running a (foreach) function on the resulting list can be simpler than stepping through a selection set.

    Kent Cooper
    Please use plain text.
    Active Member
    Posts: 7
    Registered: ‎01-29-2007

    Re: Convert Ellipse segment into spline or polyline

    05-07-2012 06:47 AM in reply to: Kent1Cooper

    Mr Cooper

     

    I have well receive your last message with namex instruction in but I don't know how do i uste it ?

    Is it a lisp instruction or a command I have to put at the command line or another way of giving instruction to ACAD.

     

    Also I joined a lisp routine that is near to perfect execpt that it don't keep original layer after transform. Could you take a look .

     

    Thank you for your help again .

    Please use plain text.
    *Expert Elite*
    Kent1Cooper
    Posts: 4,080
    Registered: ‎09-13-2004

    Re: Convert Ellipse segment into spline or polyline

    05-07-2012 07:34 AM in reply to: plap1

    plap1 wrote:

    .... 

    I have well receive your last message with namex instruction in but I don't know how do i uste it ?

    .... 

    Also I joined a lisp routine that is near to perfect execpt that it don't keep original layer after transform. ....


    You use it as in my first post on this thread, where

      (mapcar 'cadr (ssnamex (ssget "X" '((0 . "ELLIPSE"))))); all Ellipse objects in list

    makes a list of all Ellipses.  You can do anything you want with that list -- it's just a list of entity names.

     

    If I understand your routine correctly [I learned only a little bit of French, and a long time ago], it is drawing an all-line-segments Polyline over the selected object(s).  It doesn't do anything at all about the Layer, so it is simply drawing the Polyline on the current Layer, whatever that is.  Something would need to be added to either set the current Layer to that of the selected object before drawing the Polyline [and presumably set it back later], or change the new Polyline to that Layer after it's drawn [which avoids the need to change or reset the current Layer].

     

    Here's one way to do the latter.  After the Polyline is drawn by the  (command "_.pline"....  line of code, do this:

     

    (vla-put-Layer (vlax-ename->vla-object (entlast)) (vla-get-Layer obj_vlax))

    Kent Cooper
    Please use plain text.
    Active Member
    Posts: 7
    Registered: ‎01-29-2007

    Re: Convert Ellipse segment into spline or polyline

    05-08-2012 05:37 AM in reply to: Kent1Cooper
    Thank you a lot, I will try and keep you inform. Have a nice day ! Pierre Lapointe ing. MULTI-TAPE (M.T.I.) INC. Masking Technologies & Innovations 680 Boul.Lemire Drummondville, Qu?. J2C-7W9 T?l 888-477-4189 poste 30, Fax 819-477-4193 plapointe@mtimasking.com
    Please use plain text.