LISP for creating a closed boundary from edges.

LISP for creating a closed boundary from edges.

manasi4532
Enthusiast Enthusiast
213 Views
10 Replies
Message 1 of 11

LISP for creating a closed boundary from edges.

manasi4532
Enthusiast
Enthusiast

I'm looking for a Lisp routine that can take a selected polyline, extrude it vertically by a specified height, and create a new closed polyline.  I have attached an example here as well. Thank you very much. 

0 Likes
214 Views
10 Replies
Replies (10)
Message 2 of 11

Sea-Haven
Mentor
Mentor

If I understand correct your trying to show a shape with a bend on one end. For me I would draw 2 plines all flat, then use Rotate3D to stand up the vertical edge. A simple procedure. But must be viewed in 3D. Or else draw it as an isometric.

 

 

SeaHaven_0-1757468664228.png

 

0 Likes
Message 3 of 11

manasi4532
Enthusiast
Enthusiast

My requirement is that when I select one of the edges, it will generate a line like the one I showed in the sample file. I’m not sure about the correct way to view that image.

0 Likes
Message 4 of 11

Kent1Cooper
Consultant
Consultant

@manasi4532 wrote:

.... take a selected polyline, extrude it vertically by a specified height .... 


I don't see anything in your sample drawing that I can correlate with the wording "extrude it vertically."  If you mean to offset upwards on paper [in the Y-axis direction], the offset direction isn't always that way in the sample -- some are sideways.  If you mean up off the paper [in the Z-axis direction, implied by the word "extrude"], there is nothing in the 3rd dimension in the sample.  Can you describe in more detail?  Show, for example, where you would pick on a given Polyline to get a given result.  And if you're really talking about Offsetting, some in the sample involve doing that with more than one edge, so what determines how many adjacent edges should be included along with a selected edge?  Etc.

Kent Cooper, AIA
0 Likes
Message 5 of 11

Sea-Haven
Mentor
Mentor

Again sounds like use isometric drafting. which I learnt when I was like 16 at High school. Doing the offset linework can then be done. Don't really need a program. do a google for drafting Isometric.

Message 6 of 11

manasi4532
Enthusiast
Enthusiast

This is how it works, but it doesn’t work well on curved sections The working procedure is as follows: Select the desired size. Select the side. Create a new area according to the selected size.

0 Likes
Message 7 of 11

Kent1Cooper
Consultant
Consultant

@manasi4532 wrote:

This is how it works....


What is "it"?  What did you make that video with?  It doesn't show the command line, so we can't tell what you're doing.  And it doesn't address the question of what is meant by "vertically" in Message 1.

Kent Cooper, AIA
0 Likes
Message 8 of 11

Kent1Cooper
Consultant
Consultant

I can sort of imagine a way to do something like what the video shows, but only because that's done in a rectangle.  Something could be made to ask for selection of a Polyline edge, and build a rectangle of the desired width extending off that edge into the Polyline.  But while it could accomplish what's in the video, in the original sample drawing where the shape is not rectangular, it would do these kinds of things:

Kent1Cooper_0-1757613441868.png

[shown with a different color for the one from each edge].  It would deal with only single edges, not the two-adjacent-edges or even five-adjacent-edges situations in some of the sample drawing's scenarios.

But I assume that's not what you want.  Maybe some of what it would do could be part of what you want, if we knew more about that.

Kent Cooper, AIA
Message 9 of 11

manasi4532
Enthusiast
Enthusiast

Here is how it works and the sample code, but it still doesn't work with shapes that have slanted, concave, or curved sections. I'd like the result to be like the file I sent you. When one side is selected, it should create a fixed shape like an isometric drawing, just as you, Sea-havan, mentioned.

 

(defun c:minus_offset_dist (/ source_data mid_edge_param mid_edge_point edge_start_point edge_end_point angle_)
  	(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
	(setq source_data (entsel "\nPick target edge of source pline: ")
		mid_edge_param (+ 0.5 (fix (vlax-curve-getparamatpoint (car source_data) (vlax-curve-getclosestpointto (car source_data) (cadr source_data)))))
		mid_edge_point (vlax-curve-getpointatparam (car source_data) mid_edge_param)
		edge_start_point (vlax-curve-getpointatparam (car source_data) (1+ (fix mid_edge_param)))
		edge_end_point (vlax-curve-getpointatparam (car source_data) (fix mid_edge_param))
		angle_ (cond
			 ((equal (cadr edge_start_point) (cadr edge_end_point)) (* pi 0.5))  
			 ((minusp (setq angle_ (atan (apply '/ (mapcar '+ '(0 0) (mapcar '- edge_end_point edge_start_point)))))) (- angle_))
			 (t (- pi angle_))
			)
	        dist 15
	)
	(vla-move (setq pline_copy (vla-copy (vlax-ename->vla-object (car source_data))))
		  (vlax-3d-point mid_edge_point)
		  (vlax-3d-point (polar mid_edge_point angle_ dist))
	)
  	(command "_bpoly" (polar mid_edge_point angle_ (* 0.5 dist)) "")
  	(entdel (car source_data))
  	(vla-erase pline_copy)
  	(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
  	(princ)
)

For more information, you can see the approach in this post. Thanks for the code from this post.   R...

0 Likes
Message 10 of 11

manasi4532
Enthusiast
Enthusiast

Thank you very much for your helpful reply.

0 Likes
Message 11 of 11

Sea-Haven
Mentor
Mentor

Have a look at this link go down a couple of pages sounds like waht you want.

 

https://www.cadtutor.net/forum/topic/98112-tapered-offsetstretch-closed-polyline-shape/

0 Likes