Author Topic: select pline origin  (Read 8708 times)

0 Members and 1 Guest are viewing this topic.

daveland

  • Guest
select pline origin
« on: September 25, 2006, 05:16:56 PM »
Does any one have a routine that allows you to select the origin of a polyline?

Example I have a boundary which is a closed polyline and i want to select a specific vertex for the starting point.  (Note: I also want to then reverse the polyline if necessary so it is going in the right direction. P.S.-I think I already have a pretty good routine for reversing.)

thanks,

Daveland

ronjonp

  • Needs a day job
  • Posts: 7531
Re: select pline origin
« Reply #1 on: September 25, 2006, 05:20:09 PM »
By "origin" do you mean centroid of a closed polyline?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

daveland

  • Guest
Re: select pline origin
« Reply #2 on: September 25, 2006, 05:22:10 PM »
I mean starting point.  In other words i want to select a vertex anywhere along a closed polyline as the starting point.

Jeff_M

  • King Gator
  • Posts: 4098
  • C3D user & customizer
Re: select pline origin
« Reply #3 on: September 25, 2006, 05:43:24 PM »
I'm not sure about an easy coding solution, but if you use Break and select the point to break at as being on a vertex, then Pedit, select the section that had the Closing segment, join, now select the other segment. You will now have a closed pline starting at the selected vertex.

Arizona

  • Guest
Re: select pline origin
« Reply #4 on: September 25, 2006, 05:48:11 PM »
That's an interesting method Jeff  :-)

LE

  • Guest
Re: select pline origin
« Reply #5 on: September 25, 2006, 06:04:02 PM »
I mean starting point.  In other words i want to select a vertex anywhere along a closed polyline as the starting point.

It won't matter if a fas or vlx file is provided?

daveland

  • Guest
Re: select pline origin
« Reply #6 on: September 25, 2006, 06:09:10 PM »
I am not sure what an FAS file is but if it works in  Autodesk Land Desktop 2006 then FAS will be fine

LE

  • Guest
Re: select pline origin
« Reply #7 on: September 25, 2006, 06:16:04 PM »
I am not sure what an FAS file is but if it works in  Autodesk Land Desktop 2006 then FAS will be fine

FAS & VLX are compiled lisp routines, let me look for those routines it was for an small civil routines I wrote in the past that do something like this:

Code: [Select]
ID_AREADER     [$(if,$(eq,$(getenv,"AutoAreaReaderGpoly"),"1"),!.)&Automatic Area And Polyline Direction Reader]^P'AREAREADER
               [--]
               [Change Polyline D&irection]^C^CRPOL
               [Remove Duplicate &Vertices]^C^CRVERTEX
               [Change &Starting Vertex]^C^CCHSVERTEX
       [Convert Circles Into Closed Polylines]^C^CCIRCLEPOLY

daveland

  • Guest
Re: select pline origin
« Reply #8 on: September 25, 2006, 06:23:55 PM »
Sorry it didn't work either.

LE

  • Guest
Re: select pline origin
« Reply #9 on: September 25, 2006, 06:29:16 PM »
Sorry it didn't work either.

Dave;

Give me some time (if you are answering to my previous post quote), to upload the routine here.... I am doing my day job now....  :-)

daveland

  • Guest
Re: select pline origin
« Reply #10 on: September 25, 2006, 06:32:05 PM »
Hey Thanks. 
I am just finishing my day job but will check back in tomorrow.

Thanks you all for your efforts this will save me a tremendous amount of work if I can get it up and running.

I will check in tomorrow morning.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: select pline origin
« Reply #11 on: September 25, 2006, 06:47:00 PM »
You can try this.  It's seems to work on my system.  No error checking, and not very pretty, but it did work on my test drawing.
Code: [Select]
(defun c:ReOrderPoly (/ Sel Pobj Pt PtList VertexPt PtListIndex PolyList StPos cnt tmpList)

(setq Sel (entsel "\n Select polyline: "))
(setq Pobj (vlax-ename->vla-object (car Sel)))
(setq Pt (getpoint "\n Select new starting point: "))
(setq PtList (vlax-get Pobj 'Coordinates))
(setq VertexPt 0)
(setq PtListIndex 0)
(repeat (/ (length PtList) 2)
 (vla-GetWidth Pobj VerTexPt 'StWd 'EndWd)
 (setq PolyList
  (cons
   (list
    VertexPt
    (list
     (nth PtListIndex PtList)
     (nth (1+ PtListIndex) PtList)
    )
    (vla-GetBulge Pobj VertexPt)
    StWd
    EndWd
   )
   PolyList
  )
 )
 (setq VertexPt (1+ VertexPt))
 (setq PtListIndex (+ 2 PtListIndex))
)
(foreach Lst PolyList
 (if (equal (list (car Pt) (cadr Pt)) (cadr Lst))
  (setq OldIndex (car Lst))
 )
)
(setq VertexPt 0)
(setq PtList nil)
(setq PolyList (reverse PolyList))
(setq StPos (vl-position (assoc OldIndex PolyList) PolyList))
(setq cnt StPos)
(repeat (length PolyList)
 (setq tmpList (nth cnt PolyList))
 (setq PtList (append PtList (cadr tmpList)))
 (vla-SetBulge Pobj VertexPt (caddr tmpList))
 (vla-SetWidth Pobj VertexPt (cadddr tmpList) (last tmpList))
 (setq VertexPt (1+ VertexPt))
 (setq cnt (1+ cnt))
 (if (> cnt (1- (length PolyList)))
  (setq cnt 0)
 )
)
(vlax-put Pobj 'Coordinates PtList)
(princ)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: select pline origin
« Reply #12 on: September 25, 2006, 06:50:12 PM »
OK... that works Tim (on the tests I did).... no need to post mine.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: select pline origin
« Reply #13 on: September 25, 2006, 06:57:16 PM »
OK... that works Tim (on the tests I did).... no need to post mine.
Thanks for testing Luis.  I wouldn't use it (at least not at my current job), but it seemed fun to try and code it.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: select pline origin
« Reply #14 on: September 25, 2006, 10:55:36 PM »
Tim,
Works here. Nice work. :-)
If you wanted to add a vertex for the new start vertex it would be easy enough if straight line segment but if on an arc it's a differant story. That's why I chose the Break command like Jeff hinted at for my BreakAll routine.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.