TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Krushert on March 06, 2009, 10:56:50 AM

Title: Adding vertices to a pline using another PLine as a template?
Post by: Krushert on March 06, 2009, 10:56:50 AM
Can Pline vertices be added to a PLine using another pline vertices as a template?  That is the question.

The picture explains a lot so see the picture.  :evil: :-)  Currently I am adding the veritices ( with a lisp but then I have move the vertices  to break line's vertices.  I have to do this a lot so I was hoping that lisp could speed this up.
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: CAB on March 06, 2009, 11:35:52 AM
Why not use this?
http://www.theswamp.org/index.php?topic=27479.0
See Twisted 8-)
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: Krushert on March 06, 2009, 12:03:51 PM
Why not use this?
http://www.theswamp.org/index.php?topic=27479.0
See Twisted 8-)

The picker option is what I need but it would not modify the green line.  It would modish the break line as described but that is not the one that I needed.   It is faster because it as adding and stretching at the same time.   I will post in the thread and see if Andrea knows what is up.  I will say that the rectangle was modified by ADT tools and the object is closed pline.  It probably the ADT modifications that is causing it to hick up.

Thanks CAB.
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: Krushert on March 06, 2009, 12:16:50 PM
It looks like I can not use DLMO because not being able to use osnaps.  IT is pretty cool routine.  :-)
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: FengK on March 07, 2009, 02:15:03 AM
The picture explains a lot so see the picture.  :evil: :-)  Currently I am adding the veritices ( with a lisp but then I have move the vertices  to break line's vertices.  I have to do this a lot so I was hoping that lisp could speed this up.

It would be helpful if you can post a sample drawing, so others would know what would be the most appropriate method to tackle the problem. Are your break lines LINEs or LWPOLYLINEs. If they are LINEs, I'd join them first into LWPOLYLINEs. I think that will simplify the programming. I'm only thinking how I would do it.
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: CAB on March 07, 2009, 08:58:12 AM
krushert,
This routine doesn't work for you?
Or you are looking for less picks?
http://www.theswamp.org/index.php?topic=18720.msg234086#msg234086 (http://www.theswamp.org/index.php?topic=18720.msg234086#msg234086)
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: Krushert on March 07, 2009, 04:52:54 PM
krushert,
This routine doesn't work for you?
Or you are looking for less picks?
http://www.theswamp.org/index.php?topic=18720.msg234086#msg234086 (http://www.theswamp.org/index.php?topic=18720.msg234086#msg234086)

CAB, I am checking from home and don't have cad installed here.  I will check on Monday with this Rountine.

It would be helpful if you can post a sample drawing, so others would know what would be the most appropriate method to tackle the problem. Are your break lines LINEs or LWPOLYLINEs. If they are LINEs, I'd join them first into LWPOLYLINEs. I think that will simplify the programming. I'm only thinking how I would do it.
I will post a dwg on Monday.  What I want to do is is Pick the PLINE then I want to add vertices to and then select the break line to be use as a template.   Then let the routine to analize the breakpoint pline to find it's vertices and then add vertice to the to the first selected pline where the breakline vertices are.

Thanks Guys and type at on Monday unless I have to repath all my users machines because of incomptant IT Contractor.   :ugly:

Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: CAB on March 07, 2009, 05:14:26 PM
I think you will need a specialized routine if you want a two pick solution.  :roll:

With the Gile's routine, I think I used 8 picks to get the results you wanted.
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: Krushert on March 09, 2009, 12:03:22 PM
I think you will need a specialized routine if you want a two pick solution.  :roll:

With the Gile's routine, I think I used 8 picks to get the results you wanted.

I actually am using RonJonp's routine that started that thread (http://www.theswamp.org/index.php?topic=18720.msg229253#msg229253).  :-D  I am doing it 8 picks and/or moves.  4 moves to add the vertices and then 4 moves to grip stretch which is probably 2 picks per stretch.  Lets see 12 details per sheet and with (lets say) 2 breaks per detail on the average .... you get the picture.

I am going to try it with Gile's routine this afternoon.  I will get back to you. Thanks.
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: Krushert on March 09, 2009, 02:14:58 PM
I think you will need a specialized routine if you want a two pick solution.  :roll:

With the Gile's routine, I think I used 8 picks to get the results you wanted.

I actually am using RonJonp's routine that started that thread (http://www.theswamp.org/index.php?topic=18720.msg229253#msg229253).  :-D  I am doing it 8 picks and/or moves.  4 moves to add the vertices and then 4 moves to grip stretch which is probably 2 picks per stretch.  Lets see 12 details per sheet and with (lets say) 2 breaks per detail on the average .... you get the picture.

I am going to try it with Gile's routine this afternoon.  I will get back to you. Thanks.

And that saves me 2 picks becuase I can use Osnaps for two vertices.  Thus I only need to grip stretch 2 points. 
Cool.  Every little helps.  Thanks CAB.
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: Krushert on March 09, 2009, 02:43:45 PM
I think you will need a specialized routine if you want a two pick solution.  :roll:

With the Gile's routine, I think I used 8 picks to get the results you wanted.

I actually am using RonJonp's routine that started that thread (http://www.theswamp.org/index.php?topic=18720.msg229253#msg229253).  :-D  I am doing it 8 picks and/or moves.  4 moves to add the vertices and then 4 moves to grip stretch which is probably 2 picks per stretch.  Lets see 12 details per sheet and with (lets say) 2 breaks per detail on the average .... you get the picture.

I am going to try it with Gile's routine this afternoon.  I will get back to you. Thanks.

And that saves me 2 picks becuase I can use Osnaps for two vertices.  Thus I only need to grip stretch 2 points. 
Cool.  Every little helps.  Thanks CAB.


WHOOAA!!!!   :-o :-o
This is what I needed.  I did not realize that I could drag/place the vertex "outside"  the pline.   4 picks, thank you very much.
Very Cool. Thanks Guys.   Sorry I did not clue into to it sooner.  :oops:
 :-D :-D


Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: ronjonp on March 09, 2009, 03:04:15 PM
Try this one....still needs alot of work (error checking)...but should do what you want in 1 pick. :-P

Code: [Select]
(defun c:breakitmeng (/ ang ds e n obj param pt pt1 pt2 pt3 pt4 width height)
  (vl-load-com)
  (if (zerop (setq ds (getvar 'dimscale)))
    (setq ds 1.0)
  )
  (if (and (setq e (entsel "\Select polyline: "))
           (setq pt (cadr e))
           (setq e (car e))
           (= (cdr (assoc 0 (entget e))) "LWPOLYLINE")
           (setq obj (vlax-ename->vla-object e))
           (setq pt (vlax-curve-getclosestpointto e pt))
           (setq param (fix (vlax-curve-getparamatpoint e pt)))
           (setq ang (angle (vlax-curve-getpointatparam e param)
                            (vlax-curve-getpointatparam e (1+ param))
                     )
           )
           (setq width (* ds 0.35))
           (setq height (* ds 0.7))
           (setq pt1 (polar pt (+ pi ang) width))
           (setq pt2 (polar pt1 (+ (angtof "67.5") ang) height))
           (setq pt3 (polar pt ang width))
           (setq pt4 (polar pt3 (+ (angtof "247.5") ang) height))
           (setq n 0)
      )
    (foreach pt (list pt1 pt2 pt4 pt3)
      (setq n (1+ n))
      (vlax-invoke obj 'addvertex (+ param n) (reverse (cdr (reverse pt))))
    )
  )
  (princ)
)
(c:breakitmeng)
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: GDF on March 09, 2009, 04:20:25 PM
breakitmeng is pretty slick.
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: Krushert on March 09, 2009, 04:27:07 PM
Cool.  But alas it not what "Exactly" need.

Let me Zoom out a little and I post a bigger picture.  I use the express tools break line to go across a series of objects.  usually the center object get vertices added to it but not always.  Hence my question about using another pline as template
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: ronjonp on March 09, 2009, 04:44:38 PM
breakitmeng is pretty slick.

Thanks Gary :)
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: ronjonp on March 09, 2009, 04:48:25 PM
Cool.  But alas it not what "Exactly" need.

Let me Zoom out a little and I post a bigger picture.  I use the express tools break line to go across a series of objects.  usually the center object get vertices added to it but not always.  Hence my question about using another pline as template

I'm still not following what you are trying to do :?
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: CAB on March 09, 2009, 08:00:36 PM
My guess is that the break symbol is not always the same size & not always in the middle and
the break symbol has extensions the extend past the pline rectangle.
Therefore he desires to match the existing break symbol.
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: Krushert on March 10, 2009, 09:17:18 AM
My guess is that the break symbol is not always the same size & not always in the middle and
the break symbol has extensions the extend past the pline rectangle.
Therefore he desires to match the existing break symbol.

Yep that is about it.  See the attached drawing.  You will notice that there are three break lines and they are interacting with the objects differently.  Hence I need place vertices to the objects that is getting "broken".  Like CAB said the break could be anywhere on the object. 

More background info:
You ask why not simply place the break symbol and trim the object to the break line.   Because I am using ADT's detail component tools to generate some of the objects.  If I explode or trim the object I lose the data that is assigned the object thus loosing the ability to use tools like "add selected" or the use of key noting.  Plus for other objects I loose efficiency of hatching objects due not being able to selelct object or ADT's another version of subtract and merge commands. 
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: alanjt on March 15, 2009, 08:03:55 PM
very nice ronjonp, thanks for sharing.
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: ronjonp on March 16, 2009, 10:03:49 AM
very nice ronjonp, thanks for sharing.

 :-)
Title: Re: Adding vertices to a pline using another PLine as a template?
Post by: CAB on March 16, 2009, 10:52:31 AM
Here is a variation of Ron's routine.
Note that there is no error checking so you must use responsible.   :evil:
Code: [Select]
(defun c:breakitmeng (/ e e2 pt n obj param vlst)
  (vl-load-com)
  (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
  (vla-StartUndoMark (vla-get-activedocument (vlax-get-acad-object)))
  (if (and (setq e (entsel "\nSelect segment on polyline to update: "))
           (setq pt (cadr e))
           (setq e (car e))
           (= (cdr (assoc 0 (entget e))) "LWPOLYLINE")
           (setq obj (vlax-ename->vla-object e))
           (setq pt (vlax-curve-getclosestpointto e pt))
           (setq param (fix (vlax-curve-getparamatpoint e pt)))
           (setq pt (vlax-curve-getpointatparam e param))
   (setq e2 (car (entsel "\nSelect polyline for breakline points: ")))
           (= (cdr (assoc 0 (entget e2))) "LWPOLYLINE")
           (setq vlst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget e2))))
           (setq vlst (cdr vlst) ; remove 1st & last vertex
vlst (reverse (cdr (reverse vlst))))
   (if (> (distance pt (car vlst))(distance pt (last vlst)))
     (setq vlst (reverse vlst))
     t
   )
           (setq n 0)
      )
    (foreach pt vlst
      (setq n (1+ n))
      (vlax-invoke obj 'addvertex (+ param n) pt)
    )
  )
  (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
  (princ)
)
<edit prompts>
<edit added UNDO>