Lisp needed

Lisp needed

Anonymous
Not applicable
2,969 Views
10 Replies
Message 1 of 11

Lisp needed

Anonymous
Not applicable

Hi,

 

Please find the attached screenshot. Below explained briefly what I need.

 

I want to generate a polyline from the START POINT to END POINT by tracing the red color rectangles.

 

Could any please help me on this.

 

Thanks

Vijay

0 Likes
Accepted solutions (1)
2,970 Views
10 Replies
Replies (10)
Message 2 of 11

Kent1Cooper
Consultant
Consultant

I don't quite understand what kind of end result you want.  Can you draw something [even approximately] and post an image with the desired result in it?

 

Also, what kind of object are the red rectangles?  And how are the Start and End points specified?

Kent Cooper, AIA
0 Likes
Message 3 of 11

Anonymous
Not applicable

 

HI Kent,

 

Thanks for the quick reply,

 

For better understanding , I have attached the screenshot 2

In this screenshot you can find the magenta color polyline, I want to generate this polyline from startpoint to end point by tracing the red rectangles.

lisp need to ask the start point and endpoint and tracing rectangles with this three steps one polyline should be generate.

 

Could you please help me on this lisp.

0 Likes
Message 4 of 11

john.uhden
Mentor
Mentor

Um, it looks to me as though it would be easier to just draw the polyline (4 picks), except maybe if the polyline wants to be on a layer other than the current, or with a specific width or color or elevation or something.

John F. Uhden

0 Likes
Message 5 of 11

Kent1Cooper
Consultant
Consultant

That looks more difficult than you might imagine.  A routine would need to figure out how the red rectangles relate to each other, as well as each one relates to both points, to have any hope of finding appropriate locations for drawing a Polyline path.

 

All sorts of questions arise....  Would there ever be more than 2 red rectangles?  Would they ever not be touching each other?  Would they ever meet at a T shape rather than an L shape, or both cross each other [an X]?  Would the desired result always need to be in orthogonal directions, or might there ever be non-orthogonal angles involved?  Would the Start point ever not be in line with the center-line of one of the rectangles, as the end point is not?  Would you be willing to restrict selection of the red rectangles to be in the order along which the path should follow them?

 

You haven't said what the red rectangles are.  I expect they're LWPolylines, but they could be [2D] Solids, 3D Solids, Traces, Blocks, 3DPolylines, made up of separate Lines, Mlines with Lines across the ends, or maybe some other things, which would have different criteria for calculating locations.  If they represent something like cable trays [whether overhead or under a raised floor], are they at different Z coordinate elevations than the Start and End points?  If so, should the path be drawn at their elevation, or at the elevation of the Start and End?  Should it be a 3D Polyline path so that it can include vertical legs to get between the cable trays [if that's what they are] and the Start and End?

 

I don't want to sound discouraging, but I expect that you could just do this manually, with [in the case of your sample image] one Mid-of-2 Object Snap at the bend between red rectangles, and one .X coordinate filter to find where the bend out of one red rectangle toward the End point goes, very quickly without any routine, or with some practice with Object-Snap Tracking [which takes some getting used to, but is pretty powerful].  And you could do a whole lot of them that way in far less time than it would take to come up with a Lisp routine that could account for all possible configurations.

Kent Cooper, AIA
Message 6 of 11

ВeekeeCZ
Consultant
Consultant

I guess you're about connecting many cables thru a channel. -- Next time post a dwg sample!!! And more explain what you're about to do.

 

I suggest to draw (manually) an axis of the channel, end to end. And then you can use following routine to connect 2 points thru the channel. New cable would be put into specific layer, change the name in the code. Axis stays intouched. See the spoiler for the code.

 

Spoiler
(vl-load-com)

(defun c:Connect2Points ( / en ex e1 e2 el p1 q1 p2 q2 pe ps la)

  (if (and (setq *c2p-en* (cond ((car (entsel (strcat "\nSelect axis polyline " (if *c2p-en* " <last>" ": ")))))
				(*c2p-en*)))
	   (= "LWPOLYLINE" (cdr (assoc 0 (entget *c2p-en*))))
	   (setq p1 (getpoint "\nSpecify 1st point: "))
	   (setq p1 (trans p1 1 0))
	   (setq q1 (vlax-curve-getClosestPointTo *c2p-en* p1))
	   (setq p2 (getpoint "\nSpecify 2nd point: "))
	   (setq p2 (trans p2 1 0))
	   (setq q2 (vlax-curve-getClosestPointTo *c2p-en* p2))
	   (setq ps (vlax-curve-getStartPoint *c2p-en*))
	   (setq pe (vlax-curve-getEndPoint *c2p-en*))
	   )
    (progn
      (setq la "cable")  						; set cable layer name
      (command "_.LAYER" "_New" la "_Color" 2 la "")                    ; set its color..
      (setq en (entmakex (append (entget *c2p-en*)
				 (list (cons 8 la)))))
      (setq el (entlast))
      (and (not (equal q1 pe 1e-6))
	   (not (equal q1 ps 1e-6))
	   (vl-cmdf "_.BREAK" en "_none" (trans q1 0 1) "_none" (trans q1 0 1))
	   (not (equal el (entlast)))
	   (setq ex (entlast))
	   )
      (if (equal q2 (vlax-curve-getClosestPointTo en q2) 1e-6)
	(if ex (entdel ex))
	(progn
	  (entdel en)
	  (setq en ex)))
      (setq ex nil
	    el (entlast))
      (and (not (equal q2 pe 1e-6))
	   (not (equal q2 ps 1e-6))
	   (vl-cmdf "_.BREAK" en "_none" (trans q2 0 1) "_none" (trans q2 0 1))
	   (not (equal el (entlast)))
	   (setq ex (entlast))
	   )
      (if (and (or (equal q1 (vlax-curve-getStartPoint en) 1e-6)
		   (equal q1 (vlax-curve-getEndPoint en) 1e-6))
	       (or (equal q2 (vlax-curve-getStartPoint en) 1e-6)
		   (equal q2 (vlax-curve-getEndPoint en) 1e-6)))
	(if ex (entdel ex))
	(progn
	  (entdel en)
	  (setq en ex)))
      (setq e1 (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 q1) (cons 8 la)))
	    e2 (entmakex (list (cons 0 "LINE") (cons 10 p2) (cons 11 q2) (cons 8 la))))
      (initcommandversion)
      (command "_.JOIN" e1 en e2 "")
      ))
  (princ)
)

 

0 Likes
Message 7 of 11

Anonymous
Not applicable

Hi Beekee,

 

Thanks for the spoiler code.

 

Attached the drawing and screenshot. Let me explain the scenario.

 

In the drawing you can find the RED color room from there cables are starting and segregating to each desk thorough magenta color raceways, We are pulling the cables from the megenta color raceways, Indraw the polyline in yellow color that is the cable. So now I want to generate the polyline to each desk by using lisp, here the raceways might more than 3 i mean rectangles.

 

My problem is here, i need to draw a polyline to each desk, i think it's more than 400 desk. I believe you understand the problem.

I want a lisp, it should ask the start point(Red color room) and end point(Desk) by selecting magenta color raceways.

 

 

 

0 Likes
Message 8 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

Yeap, I understood the issue well. The routine works good. As I described the workflow before -- draw an axis of the raceways as polylines, then use the routine. Fast and easy.

 

See the the SCREENCAST

0 Likes
Message 9 of 11

Anonymous
Not applicable

Wow..

 

Thanks a lot Beekee.

 

You make my work easy.

 

Thank you very much again.

 

 

0 Likes
Message 10 of 11

john.uhden
Mentor
Mentor
This may sound counterproductive, but having installed over 3000 runs
(without a redo), I think the installation contractor can figure them out
on site. He can see the snags and work around them knowing what equipment
he has to deal with the troublesome runs. And what's another switch or ten
if all you can fit is one wire over 300 feet? 3', 7' 10', 50' patch cord,
who cares? The as-built plan is more important.

John F. Uhden

0 Likes
Message 11 of 11

Anonymous
Not applicable

Hi John,

 

That is just an example drawing, those yellow cables is only to get the whole cable lengths to order the patch cords boxes,  i wont keep them after get the length, I will delete the layer.  

No worries.

0 Likes