Jump to content

Can I use automation to connect 8100 lines end-to-end?


Recommended Posts

Posted

Hello everyone!

 

I'm still new here (2nd post), but I was wondering if anyone can help me figure out a way to connect a whole bunch of (8100) lines together end-to-end?

 

Basically what I have is a series of polar arrays, which do not line up just right. On similar things I was using Object Snap and connecting the lines with the mouse, but now with so many lines that would take at least 22 hours to adjust everything.

 

Can someone please help me write a little macro or something to make this job a bit easier? Basically what it would need to do is start at the bottom and adjust each upper row to connect on the corresponding endpoints of the next array.

  • I have included a few screen shots of what my arrays look like. Each individual line is 111.11111111mm, and you can see that I changed one of the arrays to green for visual clarity.

  • The second image is an example of the misalignment of the ray endpoints on a greater magnification. The differences range from less than half a millimeter to a few more than 10 mm. I used the line tool to draw a rubber band between two of the endpoints that need to be connected for visual clarity. The rubber-band is not a permanent line, just a visual aid to show the discrepancy.

Thanks for your help!

mac1.jpg

mac2.jpg

Posted

I don't know what this is for, but would it be easier just to redraw the array in a way that wouldn't leave the ends disconnected and slightly shifted? Just a thought....

Posted

Thanks for your quick reply, Crazy J!

 

I'm not sure if that is possible because I have the precision setting maxed out. This seems to be the closest that the CAD program can line them up. Another problem is that the arrays don't follow perfect arcs after they are in place.

Posted

I'm with crazyj;

Delete them all except one set of blue-green-blue.

Use grips to get the ends of these three lines together and then polar array them to get back to what you had but with the line ends co-incident.

Should take about 5 mins.

Posted

The third line (the rubber band one) is just to help visualize the misalignment. Since the arrays don't follow a perfect arc, only the 2 outside lines actually align properly.

 

The screen shots should have all the necessary information. I believe that I need to somehow select each ray and then Object Snap its top endpoint to the bottom endpoint of the ray above it.

Posted
Then screen shots should have all the necessary information.

 

A lot easier to code from a DWG.

Posted

Here is a quick DWG that I made to simplify the problem. In the project, there are almost 100 arrays!

 

This sample DWG is hopefully enough to write a script, I just need something that can connect the endpoints from the lower array to those of the upper. It is going to take 20-40 hours to move each line by hand, even if I could do 2 at a time that would be a huge improvement. Like, maybe I could use a crossing window to pick 2 endpoints and use a macro to combine them?

OsnapExamp.dwg

Posted

Found a couple of things the two arrayed objects have been created differently hence the mismatch the white has a radius of 14.1421 and the blue 14.4325 hence the gap varies across every single pair no simple soloution, personally in the time it has taken me to write this I would have redrawn them all!

 

Also checked as per the radius the angle of the lines is different I would ask the question before making a join what is the correct angular soloution as well.

 

Just redo using array with multiple objects

Posted

Well, the thing is that the arrays are supposed to have different radius points, so the connected rays can have a regular angle change. I did mean to draw the lines the same size, though.

 

Basically all I want to do is take the top endpoint of a ray on the bottom tier, and Object Snap it to the bottom endpoint of the ray directly above it. The only thing is that I have to do this 8,100 times.

Posted

But even something where I could window two endpoints and hit enter to connect them would save a huge amount of time.

Posted

Please Try:

 

 

(defun c:connect (/ end fuzz pt ron ss sset)
   (if (and (setq ss (ssget '((0 . "line"))))
            (setq fuzz 0.20)
       )
       (foreach x (setq sset (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))

           (foreach p (list (vlax-curve-getstartpoint x)
                            (vlax-curve-getendpoint x)
                      )
               (foreach y sset
                   (if
                       (and (not (equal (vlax-curve-getclosestpointto y p)
                                        p
                                        1e-11
                                 )
                            )

                            (or (<= (distance (setq pt (vlax-curve-getstartpoint y)) p)
                                    fuzz
                                )
                                (<= (distance (setq pt (vlax-curve-getendpoint y)) p)
                                    fuzz
                                )
                            )
                            (not (equal x y))
                            (> (cadr p) (cadr pt))
                       )
                          (entmod
                              (subst (cons (setq end (if (equal p (vlax-curve-getstartpoint x))
                                                         10
                                                         11
                                                     )
                                           )
                                           pt
                                     )
                                     (assoc end (setq ron (entget x)))
                                     ron
                              )
                          )
                   )
               )
           )
       )
   )
   (princ)
)

Posted

:shock: Woah, thanks wizman!

 

Can you tell me a little about this code? I have only used one macro before.

 

Would I add this through the CUI command?

Posted

How to use? Just copy and paste to notepad then save as connect.lsp. then type in command line Appload then look for the file. To start it just type connect. If i understood your problem correctly, this lisp will prompt you to select all the lines then it will connect each top endpoint bottom tiers to bottom endpoint of tier above it if the gap is within 0.20units.

Posted

Perhaps in this day of automation, you have forgotten the Pedit command.

 

This will join two non-colinear lines by extending one until it meets the other, and then make one polyline.

 

Since your two lines are at different angles, you will never be able to make one straight line of them both.

Posted

If you want to keep the lines in their existing layers, there is always the command Fillet.

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...