Adding perpendicular lines to multiple polylines

Adding perpendicular lines to multiple polylines

Anonymous
Not applicable
2,524 Views
5 Replies
Message 1 of 6

Adding perpendicular lines to multiple polylines

Anonymous
Not applicable

I have around 200 lines in my drawing that need 2 lines added perpendicular on either side of them. Screenshots attached to explain better what I need to do.

 

Is there anyway to make this process faster than just draw line, rotate and copy over to the other side?

0 Likes
Accepted solutions (1)
2,525 Views
5 Replies
Replies (5)
Message 2 of 6

tramber
Advisor
Advisor
Accepted solution

Done rapidely :

 

(defun c:func( / sel compt ent lg angle12 *osmode*)
 (setq sel(ssget '((0 . "LINE")))
  compt -1
  lg 10. ; Your length
  *osmode*(getvar"osmode"))
 (setvar"osmode"0)
 (repeat(sslength sel)
  (setq ent(ssname sel(setq compt(1+ compt)))
   angle12(angle(cdr(assoc 10(entget ent)))(cdr(assoc 11(entget ent)))))
  (command "_line"
  (polar(cdr(assoc 10(entget ent)))   (+(* pi 0.5)angle12)   (/ lg 2.))
  (polar(cdr(assoc 10(entget ent)))   (+(* pi 1.5)angle12)   (/ lg 2.))"")
  (command "_line"
  (polar(cdr(assoc 11(entget ent)))   (+(* pi 0.5)angle12)   (/ lg 2.))
  (polar(cdr(assoc 11(entget ent)))   (+(* pi 1.5)angle12)   (/ lg 2.))"")
  )
 (setvar"osmode"*osmode*)
 (princ(strcat"\n"(itoa(1+ compt))" objects"))
 (princ)
 )

Don't forget to put your length instead of 10.

Laod it in a lisp file and enter FUNC to run it.


EESignature

Message 3 of 6

Anonymous
Not applicable

Exactly what was looking for!

 

This community amazes me sometimes.

 

Thanks.

0 Likes
Message 4 of 6

tramber
Advisor
Advisor

It's done very (very) fast. That is why. And it is worldwide and I'm awake !

By the way, I slightly modified it so it appears a bit more elegant.

 

 


EESignature

Message 5 of 6

Kent1Cooper
Consultant
Consultant

@tramber wrote:

....
  (setq ent(ssname sel(setq compt(1+ compt)))
   angle12(angle(cdr(assoc 10(entget ent)))(cdr(assoc 11(entget ent)))))

....


That will work to put them on the ends of Lines, but not Polylines  as in the Subject line.  If this is the solution, then the Subject line is mis-worded.  Whether or not the OP really needs it only for Lines, I wouldn't want others looking for one to do it on Polylines to think that this is going to work.

Kent Cooper, AIA
0 Likes
Message 6 of 6

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

@tramber wrote:

....
   angle12(angle(cdr(assoc 10(entget ent)))(cdr(assoc 11(entget ent)))))

....


That will work to put them on the ends of Lines, but not Polylines  as in the Subject line.  If this is the solution, then the Subject line is mis-worded.  Whether or not the OP really needs it only for Lines, I wouldn't want others looking for one to do it on Polylines to think that this is going to work.


If you want something that will  work on Polylines, as well as Lines, Arcs, open-ended Splines or Ellipses, even closed  Polylines/Splines/Ellipses & Circles [though in such cases it will put one  marker at the location that is both "ends" of a closed object], you can use the DIV+ command in DivideMeasurePlus.lsp, available here.  It has an option to mark the division points with Lines [one of two options beyond just Points or Blocks as in regular DIVIDE], for which you specify the length.  When it asks how many segments to divide into, say 1 [regular DIVIDE doesn't allow that], and when it asks whether to put them at the ends  [regular DIVIDE doesn't have that option], say Yes.  Accept the defaults for everything else except if you want to specify a Layer other than the default current one.  Then go around and pick things of any of those types, and it will mark their ends with Lines, centered on and perpendicular to the end points.  It remembers all your choices and offers them as defaults on subsequent use.

Kent Cooper, AIA
0 Likes