AutoCAD Architecture Customization
Welcome to Autodesk’s AutoCAD Architecture Customization Forums. Share your knowledge, ask questions, and explore popular AutoCAD Architecture Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Finding a midpoint

12 REPLIES 12
Reply
Message 1 of 13
Anonymous
446 Views, 12 Replies

Finding a midpoint

I have been searching for a lisp routine that will allow me to pick a midpoint between two selection points. Most that I have found will find the point but not allow me to cintinye the comand. i.e. if I need to find the center of a room to mirrow about the centerline I would like to select a near-to point on opposing walls (transparently)which would return the centerpoint. Suggestions would be greatly appreciated!

Mark Reilly, AIA
Solana Beach, CA
12 REPLIES 12
Message 2 of 13
Anonymous
in reply to: Anonymous

Give this guy a go.

 

;;;
----------------------------------------------------------------------
;;;
Function  : Midpoint in 3D
;;;
----------------------------------------------------------------------
(defun
MID3D (/ pt1 pt2)
  (setq pt1 (getpoint "\nPick first point:
")
 pt2 (getpoint "\nPick second point: ")
  )
  (mapcar
'+ pt1 (mapcar '/ (mapcar '- pt2 pt1) '(2.0 2.0 2.0)))
)


--
Regards

 

Chad Smith
CAD Manager / Design Draftsman
Spaceframe Buildings Pty
Ltd
www.spaceframe.com


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
have been searching for a lisp routine that will allow me to pick a midpoint
between two selection points. Most that I have found will find the point but
not allow me to cintinye the comand. i.e. if I need to find the center of a
room to mirrow about the centerline I would like to select a near-to point on
opposing walls (transparently)which would return the centerpoint. Suggestions
would be greatly appreciated!

Mark Reilly, AIA
Solana Beach, CA

Message 3 of 13
Anonymous
in reply to: Anonymous

All those Mapcar's make my eyes cross and my head
hurt <g>

 

(defun MidPoint (pt1 pt2)
 
(mapcar

    '(lambda (x y)

        (* 0.5
(+ x y))

     )

     pt1 pt2

  )
)



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

Give this guy a go.

 

;;;
----------------------------------------------------------------------
;;;
Function  : Midpoint in 3D
;;;
----------------------------------------------------------------------
(defun
MID3D (/ pt1 pt2)
  (setq pt1 (getpoint "\nPick first point:
")
 pt2 (getpoint "\nPick second point: ")
  )
 
(mapcar '+ pt1 (mapcar '/ (mapcar '- pt2 pt1) '(2.0 2.0
2.0)))
)


--
Regards

 

Chad Smith
CAD Manager / Design Draftsman
Spaceframe Buildings Pty
Ltd
www.spaceframe.com


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
have been searching for a lisp routine that will allow me to pick a midpoint
between two selection points. Most that I have found will find the point but
not allow me to cintinye the comand. i.e. if I need to find the center of a
room to mirrow about the centerline I would like to select a near-to point
on opposing walls (transparently)which would return the centerpoint.
Suggestions would be greatly appreciated!

Mark Reilly, AIA
Solana Beach,
CA

Message 4 of 13
Anonymous
in reply to: Anonymous

Without any mapcar and lambda. 😉

 

It doesn't snap to anything it should not snap to.
Otherwise you never know if the midpoint really is the midpoint. Works also in
3D.

 

Use it like this:

Command: line
Specify first point:
'MPT

First point:
Second point:

Specify next point or [Undo]:

etc.

 

(defun c:mpt (/ pt1 pt2)
  (if
(and
        (= (getvar "cmdactive")
1)
        (setq pt1 (getpoint "\nFirst
point: "))
        (setq pt2 (getpoint pt1
"\nSecond point: "))
    )
    (command

      "_non"
     
(list
        (/ (+ (car pt1) (car pt2))
2)
        (/ (+ (cadr pt1) (cadr pt2))
2)
        (/ (+ (caddr pt1) (caddr pt2))
2)
      )
    )
 
)
  (princ)
)


--
Best Regards, Jimmy B
CAD and Database Developer Manager at

href="http://www.pharmadule-emtunga.com">www.pharmadule-emtunga.com

Take
a look at the trial version of SmartPurger (now for AutoCAD 2004) or
download
some freeware at www.jtbworld.com
More
on AutoCAD 2004;

href="http://www.jtbworld.com/autocad2004.htm">www.jtbworld.com/autocad2004.htm


href="http://www.jtbworld.com/autocad2004tips.htm">www.jtbworld.com/autocad2004tips.htm

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

All those Mapcar's make my eyes cross and my head
hurt <g>

 

(defun MidPoint (pt1 pt2)
 
(mapcar

    '(lambda (x y)

        (* 0.5
(+ x y))

     )

     pt1 pt2

  )
)



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

Give this guy a go.

 

;;;
----------------------------------------------------------------------
;;;
Function  : Midpoint in 3D
;;;
----------------------------------------------------------------------
(defun
MID3D (/ pt1 pt2)
  (setq pt1 (getpoint "\nPick first point:
")
 pt2 (getpoint "\nPick second point: ")
  )
 
(mapcar '+ pt1 (mapcar '/ (mapcar '- pt2 pt1) '(2.0 2.0
2.0)))
)


--
Regards

 

Chad Smith
CAD Manager / Design Draftsman
Spaceframe Buildings
Pty Ltd
www.spaceframe.com


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
have been searching for a lisp routine that will allow me to pick a
midpoint between two selection points. Most that I have found will find
the point but not allow me to cintinye the comand. i.e. if I need to find
the center of a room to mirrow about the centerline I would like to select
a near-to point on opposing walls (transparently)which would return the
centerpoint. Suggestions would be greatly appreciated!

Mark Reilly, AIA
Solana Beach,
CA

Message 5 of 13
Anonymous
in reply to: Anonymous

Or just (cal "mee")
assuming you have
(arxload "geomcal")

"Jimmy B" wrote in message
news:69FB1D230013DBE2262D196D2A86EE54@in.WebX.maYIadrTaRb...
> Without any mapcar and lambda. 😉
>
> It doesn't snap to anything it should not snap to. Otherwise you never know if the
midpoint really is the midpoint. Works also in 3D.
>
> Use it like this:
> Command: line
> Specify first point: 'MPT
> First point:
> Second point:
> Specify next point or [Undo]:
> etc.
>
> (defun c:mpt (/ pt1 pt2)
> (if (and
> (= (getvar "cmdactive") 1)
> (setq pt1 (getpoint "\nFirst point: "))
> (setq pt2 (getpoint pt1 "\nSecond point: "))
> )
> (command
> "_non"
> (list
> (/ (+ (car pt1) (car pt2)) 2)
> (/ (+ (cadr pt1) (cadr pt2)) 2)
> (/ (+ (caddr pt1) (caddr pt2)) 2)
> )
> )
> )
> (princ)
> )
>
> --
> Best Regards, Jimmy B
> CAD and Database Developer Manager at www.pharmadule-emtunga.com
> Take a look at the trial version of SmartPurger (now for AutoCAD 2004) or
> download some freeware at www.jtbworld.com
> More on AutoCAD 2004;
> www.jtbworld.com/autocad2004.htm
> www.jtbworld.com/autocad2004tips.htm
>
>
> "Bobby C. Jones" wrote in message
news:3E016A3EAAD1497BBF505A7DC629AE8A@in.WebX.maYIadrTaRb...
> All those Mapcar's make my eyes cross and my head hurt
>
> (defun MidPoint (pt1 pt2)
> (mapcar
> '(lambda (x y)
> (* 0.5 (+ x y))
> )
> pt1 pt2
> )
> )
>
> --
> Bobby C. Jones
> www.AcadX.com
> "Chad Smith" wrote in message
news:8D41760C54015298F11625934E0A9399@in.WebX.maYIadrTaRb...
> Give this guy a go.
>
> ;;; ----------------------------------------------------------------------
> ;;; Function : Midpoint in 3D
> ;;; ----------------------------------------------------------------------
> (defun MID3D (/ pt1 pt2)
> (setq pt1 (getpoint "\nPick first point: ")
> pt2 (getpoint "\nPick second point: ")
> )
> (mapcar '+ pt1 (mapcar '/ (mapcar '- pt2 pt1) '(2.0 2.0 2.0)))
> )
>
> --
> Regards
>
> Chad Smith
> CAD Manager / Design Draftsman
> Spaceframe Buildings Pty Ltd
> www.spaceframe.com
> "markbrionreilly" wrote in message
news:f1672ee.-1@WebX.maYIadrTaRb...
> I have been searching for a lisp routine that will allow me to pick a midpoint
between two selection points. Most that I have found will find the point but not allow me
to cintinye the comand. i.e. if I need to find the center of a room to mirrow about the
centerline I would like to select a near-to point on opposing walls (transparently)which
would return the centerpoint. Suggestions would be greatly appreciated!
> Mark Reilly, AIA
> Solana Beach, CA
>
Message 6 of 13
Anonymous
in reply to: Anonymous

(cal "mee") might give you the wrong midpoint depending on the snap
settings.
And it's only between two endpoints.

--
Best Regards, Jimmy B
CAD and Database Developer Manager at www.pharmadule-emtunga.com
Take a look at the trial version of SmartPurger (now for AutoCAD 2004) or
download some freeware at www.jtbworld.com
More on AutoCAD 2004;
www.jtbworld.com/autocad2004.htm
www.jtbworld.com/autocad2004tips.htm


"Doug Broad" wrote in message
news:DD6881232B8DC8563E3AC9033B618D6A@in.WebX.maYIadrTaRb...
> Or just (cal "mee")
> assuming you have
> (arxload "geomcal")
>
> "Jimmy B" wrote in message
> news:69FB1D230013DBE2262D196D2A86EE54@in.WebX.maYIadrTaRb...
> > Without any mapcar and lambda. 😉
> >
> > It doesn't snap to anything it should not snap to. Otherwise you never
know if the
> midpoint really is the midpoint. Works also in 3D.
> >
> > Use it like this:
> > Command: line
> > Specify first point: 'MPT
> > First point:
> > Second point:
> > Specify next point or [Undo]:
> > etc.
> >
> > (defun c:mpt (/ pt1 pt2)
> > (if (and
> > (= (getvar "cmdactive") 1)
> > (setq pt1 (getpoint "\nFirst point: "))
> > (setq pt2 (getpoint pt1 "\nSecond point: "))
> > )
> > (command
> > "_non"
> > (list
> > (/ (+ (car pt1) (car pt2)) 2)
> > (/ (+ (cadr pt1) (cadr pt2)) 2)
> > (/ (+ (caddr pt1) (caddr pt2)) 2)
> > )
> > )
> > )
> > (princ)
> > )
> >
> > --
> > Best Regards, Jimmy B
> > CAD and Database Developer Manager at www.pharmadule-emtunga.com
> > Take a look at the trial version of SmartPurger (now for AutoCAD 2004)
or
> > download some freeware at www.jtbworld.com
> > More on AutoCAD 2004;
> > www.jtbworld.com/autocad2004.htm
> > www.jtbworld.com/autocad2004tips.htm
> >
> >
> > "Bobby C. Jones" wrote in message
> news:3E016A3EAAD1497BBF505A7DC629AE8A@in.WebX.maYIadrTaRb...
> > All those Mapcar's make my eyes cross and my head hurt
> >
> > (defun MidPoint (pt1 pt2)
> > (mapcar
> > '(lambda (x y)
> > (* 0.5 (+ x y))
> > )
> > pt1 pt2
> > )
> > )
> >
> > --
> > Bobby C. Jones
> > www.AcadX.com
> > "Chad Smith" wrote in message
> news:8D41760C54015298F11625934E0A9399@in.WebX.maYIadrTaRb...
> > Give this guy a go.
> >
> >


;;; ----------------------------------------------------------------------
> > ;;; Function : Midpoint in 3D
> >


;;; ----------------------------------------------------------------------
> > (defun MID3D (/ pt1 pt2)
> > (setq pt1 (getpoint "\nPick first point: ")
> > pt2 (getpoint "\nPick second point: ")
> > )
> > (mapcar '+ pt1 (mapcar '/ (mapcar '- pt2 pt1) '(2.0 2.0 2.0)))
> > )
> >
> > --
> > Regards
> >
> > Chad Smith
> > CAD Manager / Design Draftsman
> > Spaceframe Buildings Pty Ltd
> > www.spaceframe.com
> > "markbrionreilly" wrote in message
> news:f1672ee.-1@WebX.maYIadrTaRb...
> > I have been searching for a lisp routine that will allow me to
pick a midpoint
> between two selection points. Most that I have found will find the point
but not allow me
> to cintinye the comand. i.e. if I need to find the center of a room to
mirrow about the
> centerline I would like to select a near-to point on opposing walls
(transparently)which
> would return the centerpoint. Suggestions would be greatly appreciated!
> > Mark Reilly, AIA
> > Solana Beach, CA
> >
>
>
Message 7 of 13
Anonymous
in reply to: Anonymous

Yes, there are limitations.
Also (cal "(cur+cur)/2")

will get any point and not specify snap

(cal "(nea+nea)/2")
will specify nearest snap etc.



"Jimmy B" wrote in message
news:195D08316022BAC94C92F74903615154@in.WebX.maYIadrTaRb...
> (cal "mee") might give you the wrong midpoint depending on the snap
> settings.
> And it's only between two endpoints.
>
> --
> Best Regards, Jimmy B
> CAD and Database Developer Manager at www.pharmadule-emtunga.com
> Take a look at the trial version of SmartPurger (now for AutoCAD 2004) or
> download some freeware at www.jtbworld.com
> More on AutoCAD 2004;
> www.jtbworld.com/autocad2004.htm
> www.jtbworld.com/autocad2004tips.htm
>
>
> "Doug Broad" wrote in message
> news:DD6881232B8DC8563E3AC9033B618D6A@in.WebX.maYIadrTaRb...
> > Or just (cal "mee")
> > assuming you have
> > (arxload "geomcal")
> >
> > "Jimmy B" wrote in message
> > news:69FB1D230013DBE2262D196D2A86EE54@in.WebX.maYIadrTaRb...
> > > Without any mapcar and lambda. 😉
> > >
> > > It doesn't snap to anything it should not snap to. Otherwise you never
> know if the
> > midpoint really is the midpoint. Works also in 3D.
> > >
> > > Use it like this:
> > > Command: line
> > > Specify first point: 'MPT
> > > First point:
> > > Second point:
> > > Specify next point or [Undo]:
> > > etc.
> > >
> > > (defun c:mpt (/ pt1 pt2)
> > > (if (and
> > > (= (getvar "cmdactive") 1)
> > > (setq pt1 (getpoint "\nFirst point: "))
> > > (setq pt2 (getpoint pt1 "\nSecond point: "))
> > > )
> > > (command
> > > "_non"
> > > (list
> > > (/ (+ (car pt1) (car pt2)) 2)
> > > (/ (+ (cadr pt1) (cadr pt2)) 2)
> > > (/ (+ (caddr pt1) (caddr pt2)) 2)
> > > )
> > > )
> > > )
> > > (princ)
> > > )
> > >
> > > --
> > > Best Regards, Jimmy B
> > > CAD and Database Developer Manager at www.pharmadule-emtunga.com
> > > Take a look at the trial version of SmartPurger (now for AutoCAD 2004)
> or
> > > download some freeware at www.jtbworld.com
> > > More on AutoCAD 2004;
> > > www.jtbworld.com/autocad2004.htm
> > > www.jtbworld.com/autocad2004tips.htm
> > >
> > >
> > > "Bobby C. Jones" wrote in message
> > news:3E016A3EAAD1497BBF505A7DC629AE8A@in.WebX.maYIadrTaRb...
> > > All those Mapcar's make my eyes cross and my head hurt
> > >
> > > (defun MidPoint (pt1 pt2)
> > > (mapcar
> > > '(lambda (x y)
> > > (* 0.5 (+ x y))
> > > )
> > > pt1 pt2
> > > )
> > > )
> > >
> > > --
> > > Bobby C. Jones
> > > www.AcadX.com
> > > "Chad Smith" wrote in message
> > news:8D41760C54015298F11625934E0A9399@in.WebX.maYIadrTaRb...
> > > Give this guy a go.
> > >
> > >
>
>
> ;;; ----------------------------------------------------------------------
> > > ;;; Function : Midpoint in 3D
> > >
>
>
> ;;; ----------------------------------------------------------------------
> > > (defun MID3D (/ pt1 pt2)
> > > (setq pt1 (getpoint "\nPick first point: ")
> > > pt2 (getpoint "\nPick second point: ")
> > > )
> > > (mapcar '+ pt1 (mapcar '/ (mapcar '- pt2 pt1) '(2.0 2.0 2.0)))
> > > )
> > >
> > > --
> > > Regards
> > >
> > > Chad Smith
> > > CAD Manager / Design Draftsman
> > > Spaceframe Buildings Pty Ltd
> > > www.spaceframe.com
> > > "markbrionreilly" wrote in message
> > news:f1672ee.-1@WebX.maYIadrTaRb...
> > > I have been searching for a lisp routine that will allow me to
> pick a midpoint
> > between two selection points. Most that I have found will find the point
> but not allow me
> > to cintinye the comand. i.e. if I need to find the center of a room to
> mirrow about the
> > centerline I would like to select a near-to point on opposing walls
> (transparently)which
> > would return the centerpoint. Suggestions would be greatly appreciated!
> > > Mark Reilly, AIA
> > > Solana Beach, CA
> > >
> >
> >
>
>
Message 8 of 13
Anonymous
in reply to: Anonymous

Still it will give you the wrong midpoint if you have resulting midpoint
close to something else that your osnap settings will snap to.

It's dangerous since you believe you got the correct midpoint but got
another point..

--
Best Regards, Jimmy B
CAD and Database Developer Manager at www.pharmadule-emtunga.com
Take a look at the trial version of SmartPurger (now for AutoCAD 2004) or
download some freeware at www.jtbworld.com
More on AutoCAD 2004;
www.jtbworld.com/autocad2004.htm
www.jtbworld.com/autocad2004tips.htm


"Doug Broad" wrote in message
news:6F13104D24E052A69E3D4E8460C31B75@in.WebX.maYIadrTaRb...
> Yes, there are limitations.
> Also (cal "(cur+cur)/2")
>
> will get any point and not specify snap
>
> (cal "(nea+nea)/2")
> will specify nearest snap etc.
>
>
>
> "Jimmy B" wrote in message
> news:195D08316022BAC94C92F74903615154@in.WebX.maYIadrTaRb...
> > (cal "mee") might give you the wrong midpoint depending on the snap
> > settings.
> > And it's only between two endpoints.
> >
> > --
> > Best Regards, Jimmy B
> > CAD and Database Developer Manager at www.pharmadule-emtunga.com
> > Take a look at the trial version of SmartPurger (now for AutoCAD 2004)
or
> > download some freeware at www.jtbworld.com
> > More on AutoCAD 2004;
> > www.jtbworld.com/autocad2004.htm
> > www.jtbworld.com/autocad2004tips.htm
> >
> >
> > "Doug Broad" wrote in message
> > news:DD6881232B8DC8563E3AC9033B618D6A@in.WebX.maYIadrTaRb...
> > > Or just (cal "mee")
> > > assuming you have
> > > (arxload "geomcal")
> > >
> > > "Jimmy B" wrote in message
> > > news:69FB1D230013DBE2262D196D2A86EE54@in.WebX.maYIadrTaRb...
> > > > Without any mapcar and lambda. 😉
> > > >
> > > > It doesn't snap to anything it should not snap to. Otherwise you
never
> > know if the
> > > midpoint really is the midpoint. Works also in 3D.
> > > >
> > > > Use it like this:
> > > > Command: line
> > > > Specify first point: 'MPT
> > > > First point:
> > > > Second point:
> > > > Specify next point or [Undo]:
> > > > etc.
> > > >
> > > > (defun c:mpt (/ pt1 pt2)
> > > > (if (and
> > > > (= (getvar "cmdactive") 1)
> > > > (setq pt1 (getpoint "\nFirst point: "))
> > > > (setq pt2 (getpoint pt1 "\nSecond point: "))
> > > > )
> > > > (command
> > > > "_non"
> > > > (list
> > > > (/ (+ (car pt1) (car pt2)) 2)
> > > > (/ (+ (cadr pt1) (cadr pt2)) 2)
> > > > (/ (+ (caddr pt1) (caddr pt2)) 2)
> > > > )
> > > > )
> > > > )
> > > > (princ)
> > > > )
> > > >
> > > > --
> > > > Best Regards, Jimmy B
> > > > CAD and Database Developer Manager at www.pharmadule-emtunga.com
> > > > Take a look at the trial version of SmartPurger (now for AutoCAD
2004)
> > or
> > > > download some freeware at www.jtbworld.com
> > > > More on AutoCAD 2004;
> > > > www.jtbworld.com/autocad2004.htm
> > > > www.jtbworld.com/autocad2004tips.htm
> > > >
> > > >
> > > > "Bobby C. Jones" wrote in message
> > > news:3E016A3EAAD1497BBF505A7DC629AE8A@in.WebX.maYIadrTaRb...
> > > > All those Mapcar's make my eyes cross and my head hurt
> > > >
> > > > (defun MidPoint (pt1 pt2)
> > > > (mapcar
> > > > '(lambda (x y)
> > > > (* 0.5 (+ x y))
> > > > )
> > > > pt1 pt2
> > > > )
> > > > )
> > > >
> > > > --
> > > > Bobby C. Jones
> > > > www.AcadX.com
> > > > "Chad Smith" wrote in message
> > > news:8D41760C54015298F11625934E0A9399@in.WebX.maYIadrTaRb...
> > > > Give this guy a go.
> > > >
> > > >
> >
> >
> >
;;; ----------------------------------------------------------------------
> > > > ;;; Function : Midpoint in 3D
> > > >
> >
> >
> >
;;; ----------------------------------------------------------------------
> > > > (defun MID3D (/ pt1 pt2)
> > > > (setq pt1 (getpoint "\nPick first point: ")
> > > > pt2 (getpoint "\nPick second point: ")
> > > > )
> > > > (mapcar '+ pt1 (mapcar '/ (mapcar '- pt2 pt1) '(2.0 2.0 2.0)))
> > > > )
> > > >
> > > > --
> > > > Regards
> > > >
> > > > Chad Smith
> > > > CAD Manager / Design Draftsman
> > > > Spaceframe Buildings Pty Ltd
> > > > www.spaceframe.com
> > > > "markbrionreilly" wrote in message
> > > news:f1672ee.-1@WebX.maYIadrTaRb...
> > > > I have been searching for a lisp routine that will allow me to
> > pick a midpoint
> > > between two selection points. Most that I have found will find the
point
> > but not allow me
> > > to cintinye the comand. i.e. if I need to find the center of a room to
> > mirrow about the
> > > centerline I would like to select a near-to point on opposing walls
> > (transparently)which
> > > would return the centerpoint. Suggestions would be greatly
appreciated!
> > > > Mark Reilly, AIA
> > > > Solana Beach, CA
> > > >
> > >
> > >
> >
> >
>
>
Message 9 of 13
Anonymous
in reply to: Anonymous

Add this to your Pop0 Menu:

[Apparent Midpoint]_non;'cal;(cur+cur)/2;^m


Cheers,

Robert Grandmaison

"markbrionreilly" wrote in message
news:f1672ee.-1@WebX.maYIadrTaRb...
> I have been searching for a lisp routine that will allow me to pick a
midpoint between two selection points. Most that I have found will find the
point but not allow me to cintinye the comand. i.e. if I need to find the
center of a room to mirrow about the centerline I would like to select a
near-to point on opposing walls (transparently)which would return the
centerpoint. Suggestions would be greatly appreciated!
> Mark Reilly, AIA
> Solana Beach, CA
>
Message 10 of 13
Anonymous
in reply to: Anonymous

I'm not sure I understand what you are saying. Cal however
just returns the point geometrically between the 2 pick points.
It does not apply any osnap to the result. If I were to give it
(cal "([0,1,2]+[2,3,4])/2")
it would return (1,2,3) regardless of any objects in the drawing.

The output of the function is just a point. It can be used
further or sent to the command line. Only when used in
a command are current osnap settings applicable. Only
then do you need to use "non" if you want it applied exactly.

This would do the same thing (exactly) as your function:
(defun c:mpt( / pt)
(setq pt (cal "(cur+cur)/2"))
(command "non" pt)
(princ))

I was just illustrating another approach entirely rather than
re-inventing the wheel(which I often do).

Enjoyed the discussion.
Doug


"Jimmy B" wrote in message
news:E7B207CC20F7FBE4364A12A6AF993103@in.WebX.maYIadrTaRb...
> Still it will give you the wrong midpoint if you have resulting midpoint
> close to something else that your osnap settings will snap to.
>
> It's dangerous since you believe you got the correct midpoint but got
> another point..
>
> --
> Best Regards, Jimmy B
> CAD and Database Developer Manager at www.pharmadule-emtunga.com
> Take a look at the trial version of SmartPurger (now for AutoCAD 2004) or
> download some freeware at www.jtbworld.com
> More on AutoCAD 2004;
> www.jtbworld.com/autocad2004.htm
> www.jtbworld.com/autocad2004tips.htm
>
>
> "Doug Broad" wrote in message
> news:6F13104D24E052A69E3D4E8460C31B75@in.WebX.maYIadrTaRb...
> > Yes, there are limitations.
> > Also (cal "(cur+cur)/2")
> >
> > will get any point and not specify snap
> >
> > (cal "(nea+nea)/2")
> > will specify nearest snap etc.
> >
> >
> >
> > "Jimmy B" wrote in message
> > news:195D08316022BAC94C92F74903615154@in.WebX.maYIadrTaRb...
> > > (cal "mee") might give you the wrong midpoint depending on the snap
> > > settings.
> > > And it's only between two endpoints.
> > >
> > > --
> > > Best Regards, Jimmy B
> > > CAD and Database Developer Manager at www.pharmadule-emtunga.com
> > > Take a look at the trial version of SmartPurger (now for AutoCAD 2004)
> or
> > > download some freeware at www.jtbworld.com
> > > More on AutoCAD 2004;
> > > www.jtbworld.com/autocad2004.htm
> > > www.jtbworld.com/autocad2004tips.htm
> > >
> > >
> > > "Doug Broad" wrote in message
> > > news:DD6881232B8DC8563E3AC9033B618D6A@in.WebX.maYIadrTaRb...
> > > > Or just (cal "mee")
> > > > assuming you have
> > > > (arxload "geomcal")
> > > >
> > > > "Jimmy B" wrote in message
> > > > news:69FB1D230013DBE2262D196D2A86EE54@in.WebX.maYIadrTaRb...
> > > > > Without any mapcar and lambda. 😉
> > > > >
> > > > > It doesn't snap to anything it should not snap to. Otherwise you
> never
> > > know if the
> > > > midpoint really is the midpoint. Works also in 3D.
> > > > >
> > > > > Use it like this:
> > > > > Command: line
> > > > > Specify first point: 'MPT
> > > > > First point:
> > > > > Second point:
> > > > > Specify next point or [Undo]:
> > > > > etc.
> > > > >
> > > > > (defun c:mpt (/ pt1 pt2)
> > > > > (if (and
> > > > > (= (getvar "cmdactive") 1)
> > > > > (setq pt1 (getpoint "\nFirst point: "))
> > > > > (setq pt2 (getpoint pt1 "\nSecond point: "))
> > > > > )
> > > > > (command
> > > > > "_non"
> > > > > (list
> > > > > (/ (+ (car pt1) (car pt2)) 2)
> > > > > (/ (+ (cadr pt1) (cadr pt2)) 2)
> > > > > (/ (+ (caddr pt1) (caddr pt2)) 2)
> > > > > )
> > > > > )
> > > > > )
> > > > > (princ)
> > > > > )
> > > > >
> > > > > --
> > > > > Best Regards, Jimmy B
> > > > > CAD and Database Developer Manager at www.pharmadule-emtunga.com
> > > > > Take a look at the trial version of SmartPurger (now for AutoCAD
> 2004)
> > > or
> > > > > download some freeware at www.jtbworld.com
> > > > > More on AutoCAD 2004;
> > > > > www.jtbworld.com/autocad2004.htm
> > > > > www.jtbworld.com/autocad2004tips.htm
> > > > >
> > > > >
> > > > > "Bobby C. Jones" wrote in message
> > > > news:3E016A3EAAD1497BBF505A7DC629AE8A@in.WebX.maYIadrTaRb...
> > > > > All those Mapcar's make my eyes cross and my head hurt
> > > > >
> > > > > (defun MidPoint (pt1 pt2)
> > > > > (mapcar
> > > > > '(lambda (x y)
> > > > > (* 0.5 (+ x y))
> > > > > )
> > > > > pt1 pt2
> > > > > )
> > > > > )
> > > > >
> > > > > --
> > > > > Bobby C. Jones
> > > > > www.AcadX.com
> > > > > "Chad Smith" wrote in message
> > > > news:8D41760C54015298F11625934E0A9399@in.WebX.maYIadrTaRb...
> > > > > Give this guy a go.
> > > > >
> > > > >
> > >
> > >
> > >
> ;;; ----------------------------------------------------------------------
> > > > > ;;; Function : Midpoint in 3D
> > > > >
> > >
> > >
> > >
> ;;; ----------------------------------------------------------------------
> > > > > (defun MID3D (/ pt1 pt2)
> > > > > (setq pt1 (getpoint "\nPick first point: ")
> > > > > pt2 (getpoint "\nPick second point: ")
> > > > > )
> > > > > (mapcar '+ pt1 (mapcar '/ (mapcar '- pt2 pt1) '(2.0 2.0 2.0)))
> > > > > )
> > > > >
> > > > > --
> > > > > Regards
> > > > >
> > > > > Chad Smith
> > > > > CAD Manager / Design Draftsman
> > > > > Spaceframe Buildings Pty Ltd
> > > > > www.spaceframe.com
> > > > > "markbrionreilly" wrote in message
> > > > news:f1672ee.-1@WebX.maYIadrTaRb...
> > > > > I have been searching for a lisp routine that will allow me to
> > > pick a midpoint
> > > > between two selection points. Most that I have found will find the
> point
> > > but not allow me
> > > > to cintinye the comand. i.e. if I need to find the center of a room to
> > > mirrow about the
> > > > centerline I would like to select a near-to point on opposing walls
> > > (transparently)which
> > > > would return the centerpoint. Suggestions would be greatly
> appreciated!
> > > > > Mark Reilly, AIA
> > > > > Solana Beach, CA
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Message 11 of 13
Anonymous
in reply to: Anonymous

And interestingly enough this seems to work also:
(defun c:mpt ()(command "non" (cal "(cur+cur)/2"))(princ))

Regards,
Doug

"Doug Broad" wrote in message
news:4378BA3CD3BDA389588822BA3A979B45@in.WebX.maYIadrTaRb...
> (defun c:mpt( / pt)
> (setq pt (cal "(cur+cur)/2"))
> (command "non" pt)
> (princ))
>
Message 11 of 13
Anonymous
in reply to: Anonymous

You can reproduce this by drawing two lines close to each other and not zoom
in too close. When you then try do find the midpoint as follow...
Command: LINE Specify first point: (cal "(cur+cur)/2")
>> Enter a point:
>> Enter a point:
...the point might start at one of the specified points instead of between
them.

Hope this clarifies it.


--
Best Regards, Jimmy B
CAD and Database Developer Manager at www.pharmadule-emtunga.com
Take a look at the trial version of SmartPurger (now for AutoCAD 2004) or
download some freeware at www.jtbworld.com
More on AutoCAD 2004;
www.jtbworld.com/autocad2004.htm
www.jtbworld.com/autocad2004tips.htm


"Doug Broad" wrote in message
news:4378BA3CD3BDA389588822BA3A979B45@in.WebX.maYIadrTaRb...
> I'm not sure I understand what you are saying. Cal however
> just returns the point geometrically between the 2 pick points.
> It does not apply any osnap to the result. If I were to give it
> (cal "([0,1,2]+[2,3,4])/2")
> it would return (1,2,3) regardless of any objects in the drawing.
>
> The output of the function is just a point. It can be used
> further or sent to the command line. Only when used in
> a command are current osnap settings applicable. Only
> then do you need to use "non" if you want it applied exactly.
>
> This would do the same thing (exactly) as your function:
> (defun c:mpt( / pt)
> (setq pt (cal "(cur+cur)/2"))
> (command "non" pt)
> (princ))
>
> I was just illustrating another approach entirely rather than
> re-inventing the wheel(which I often do).
>
> Enjoyed the discussion.
> Doug
>
>
Message 13 of 13
Anonymous
in reply to: Anonymous

This one does indeed work. 101 ways to find the midpoint. 😉

--
Best Regards, Jimmy B
CAD and Database Developer Manager at www.pharmadule-emtunga.com
Take a look at the trial version of SmartPurger (now for AutoCAD 2004) or
download some freeware at www.jtbworld.com
More on AutoCAD 2004;
www.jtbworld.com/autocad2004.htm
www.jtbworld.com/autocad2004tips.htm


"Doug Broad" wrote in message
news:0CFD644D0826D32CBA3A8E3E4AF25614@in.WebX.maYIadrTaRb...
> And interestingly enough this seems to work also:
> (defun c:mpt ()(command "non" (cal "(cur+cur)/2"))(princ))
>
> Regards,
> Doug
>
> "Doug Broad" wrote in message
> news:4378BA3CD3BDA389588822BA3A979B45@in.WebX.maYIadrTaRb...
> > (defun c:mpt( / pt)
> > (setq pt (cal "(cur+cur)/2"))
> > (command "non" pt)
> > (princ))
> >
>
>

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

Post to forums  

Autodesk Design & Make Report

”Boost