Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

XLINE between two midpoints

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
viktors.zilinskis
1114 Views, 5 Replies

XLINE between two midpoints

Hi! I am trying to create a new sipmle command that would allow to draw an xline between two midpoints:

(defun c:xlm()(command "xline" "m2p" pause pause "m2p" pause pause))

 For some reason it works just fine with the first midpoint, but not the other one. Any suggestions would be appreciated! 

5 REPLIES 5
Message 2 of 6
hmsilva
in reply to: viktors.zilinskis


@viktors.zilinskis wrote:

Hi! I am trying to create a new sipmle command that would allow to draw an xline between two midpoints:

 For some reason it works just fine with the first midpoint, but not the other one. Any suggestions would be appreciated! 


Hi  Viktors,

 

perhaps something like this

 

(defun c:xlm ( / p1 p2 p3 p4)
  (if (and (setq p1 (getpoint "\nFirst point of mid: "))
    (setq p2 (getpoint "\nSecond point of mid: "))
    (setq p3 (mapcar '* '(0.5 0.5 0.5) (mapcar '+ p1 p2)))
    (setq p1 (getpoint p3 "\nFirst point of mid: "))
    (setq p2 (getpoint p3 "\nSecond point of mid: "))
    (setq p4 (mapcar '* '(0.5 0.5 0.5) (mapcar '+ p1 p2)))
    );; and
    (command "_.xline" "_NONE" p3 "_NONE" p4 "")
    )
  (princ)
  )

 

HTH

Henrique

EESignature

Message 3 of 6
viktors.zilinskis
in reply to: hmsilva

Hi! Thanks, this worked like a charm! I still don't get why my command didn´t work though... 

Message 4 of 6

Also..

 

(defun c:xlm()
    (command "xline" "m2p" pause "m2p" pause "")
)

 

Message 5 of 6

This one works perfectly well as well and is really interesting... I believed that one has to use PAUSE for every click one wants to get from user. It seems though that it stands for every point that has to be defined for the XLINE command (which would be 2 points, but 4 clicks if using M2P modifier). Thanks!

Message 6 of 6

If you're using this to draw an Xline halfway between and parallel to two parallel straight things, or to bisect the angle between two straight things under the right kinds of circumstances*, try the BI command in Bisector.lsp here.  It gets you there by picking the two objects rather than four points.  It works with virtually anything straight -- Lines, Polyline line segments, Multilines, straight-format Leaders, Xlines, Rays, linear elements of Dimensions, pieces of Hatch patterns [with snapping to them enabled in newer versions where that's optional], 3DFaces, 2D Solids, straight edges of 3D Solids and Regions, Traces, such things when they're parts of Blocks, and even unlikely things like the edges of Images and Viewports and Tolerance boxes.  If you either miss or pick something that isn't straight, it asks again.  If the two selected things are parallel, it draws an Xline halfway between them.  If they're not, it draws one bisecting the angle between them.

 

It also works in older versions of AutoCAD that don't have the M2P Object-Snap mode available.

 

* I say "under the right kinds of circumstances" because there can be different results from the two approaches, mostly depending on whether the situation is symmetrical or not, as illustrated.  In the four-point-pick approach, you would pick the four ends of the two red Lines [in the right order, of course]; in the BI command, you would pick the two red Lines once each, anywhere on them.

 

Bisector.png

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost