Jump to content

Distances on a Polyline


Jozi68

Recommended Posts

  • Replies 63
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    29

  • fuqua

    23

  • Jozi68

    6

  • stevesfr

    4

Ok, thanks. :)

 

Try this as a preliminary:

 

(defun c:IntLen (/ cEnt cObj ss ObjLst Len)
 (vl-load-com)
 (if (and (setq cEnt (car (entsel "\nSelect Main Polyline: ")))
          (eq "AcDbPolyline"
            (vla-get-ObjectName
              (setq cObj (vlax-ename->vla-object cEnt)))))
   (progn
     (setq ss (ssget "_X" (list (cons 0 "LWPOLYLINE")
                                (cons 410 (getvar "CTAB")))))
     (ssdel cEnt ss)
     (if (> (sslength ss) 0)
       (progn
         (setq ObjLst
           (mapcar 'vlax-ename->vla-object
             (mapcar 'cadr (ssnamex ss))))
         (setq ObjLst
           (vl-remove-if-not
             (function
               (lambda (x)
                 (vlax-invoke cObj 'IntersectWith x acExtendNone))) ObjLst))
         (mapcar
           (function
             (lambda (x)
               (redraw (vlax-vla-object->ename x) 3))) Objlst)
         (setq Len (apply '+ (mapcar 'vla-get-Length ObjLst)))
         (princ (strcat "\n<< Total Length of " (rtos (length ObjLst) 2 0)
                         " Polylines = " (rtos Len 2 2) " >>")))
       (princ "\n<< No Intersecting Polylines Found >>")))
   (princ "\n<< No Polyline Selected >>"))
 (princ))

 

Just do a regen to "unhighlight" - you'll see what I mean.

Link to comment
Share on other sites

wow you already wrote it ?! will have to try this tomorrow when im back at work though.

 

what does it do so far ?

 

At the moment, it will calculate the total length of all the intersecting polylines - and will highlight those polylines to show you which ones it has used for the calculation.

 

I haven't gone into the whole "border" issue yet, but we can go into that later, if you are happy with this one.

Link to comment
Share on other sites

can u make it like it needs a object as a starting point ? damn i wish i was at work right now to try it out. will be first thing early morning tomorrow though.

 

if i find out how ill post a picture here to show you how im using autocad for work. maybe that will make my intent more clear.

Link to comment
Share on other sites

can u make it like it needs a object as a starting point ? damn i wish i was at work right now to try it out. will be first thing early morning tomorrow though.

 

if i find out how ill post a picture here to show you how im using autocad for work. maybe that will make my intent more clear.

 

 

At the moment, you have to select the "Main Polyline" from which all calculations are made.

Link to comment
Share on other sites

ok its no problem mate, ill give this a trail run tomorrow morning. again im very grateful for your help.

 

Ok, I look forward to your feedback :D

Link to comment
Share on other sites

hi mate !

 

i just gave it a trail run, and it seems that for some reason it wont select/see all polylines connected to the main polyline.

 

it will select some but not all.

Link to comment
Share on other sites

I can't get it to fail my end :unsure:

 

that is strange :S how many polylines do u have connected to the main one ? i got something over 44 lines

Link to comment
Share on other sites

that is strange :S how many polylines do u have connected to the main one ? i got something over 44 lines

 

Just tried it with 27 (all I could be bothered to draw) - and no problem.

 

1) Are you sure all the lines are LWPOLYLINEs?

 

2) Are you sure there is no Z-coord involved?

 

3) Are you able to post a sample drawing?

Link to comment
Share on other sites

Just tried it with 27 (all I could be bothered to draw) - and no problem.

 

1) Are you sure all the lines are LWPOLYLINEs?

 

2) Are you sure there is no Z-coord involved?

 

3) Are you able to post a sample drawing?

 

as far as i can tell im using the normal standard polyline provided by autocad 2009.

 

i know of 2 types of lines, a normal one and a polyline. can u tell me how i can check for a lw polyline, i thought lw just stood for "lineweight".

 

no z-coord are involved.

 

here's a pic.

 

sampley.jpg

Link to comment
Share on other sites

I can't get it to fail my end :unsure:

 

Lee, I have to agree with Fuqua, only lines on one side (right side from starting point of pline) are recognized by the code in my ac 8 dwg. Those on opposite side are ignored for some reason.

Steve

Link to comment
Share on other sites

Lee, I have to agree with Fuqua, only lines on one side (right side from starting point of pline) are recognized by the code in my ac 8 dwg. Those on opposite side are ignored for some reason.

Steve

 

with me dwg file saved in AC2k4, but autocad 2009.

 

but it seems to be utterly random with me, sometimes it sees 3 other time 18, sometimes (and that is great) it also recognizes another line's connected through a object.

Link to comment
Share on other sites

Guys, this only uses the IntersectWith method - which doesn't take into account which "side" of the polyline it is on.

 

Could you not attach a dwg file so that I could experiment?

Link to comment
Share on other sites

Guys, this only uses the IntersectWith method - which doesn't take into account which "side" of the polyline it is on.

 

Could you not attach a dwg file so that I could experiment?

 

could do that tomorrow, can only give u the file with polylines though.

 

so ur saying that the lines it DOES see are intersecting ? (if so, then im making a mistake in my drawing, cause some lines are "forbidden" to intersect).

Link to comment
Share on other sites

so ur saying that the lines it DOES see are intersecting ? (if so, then im making a mistake in my drawing, cause some lines are "forbidden" to intersect).

 

You asked me to retrieve the lengths of all polylines that are touching a main polyline didn't you?

 

Hence this code will do just that.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...