Author Topic: dimension from mid of two points  (Read 3451 times)

0 Members and 1 Guest are viewing this topic.

danny

  • Guest
dimension from mid of two points
« on: March 22, 2005, 06:54:49 PM »
trying to create a function that will dimension from the middle of to selected points to the middle of to selected points.  Basically from the middle of a wall to the middle of a wall.
I have this as a start, but I get nil.
Code: [Select]
;sets dimension from the mid of 2 selected points to the mid of 2 selected points
(DEFUN C:dimmid()
(setq oldos (getvar "osmode"))
(setvar "osmode" 703)
(setq pt1 (getpoint "\nPick first point: "))
(setvar "osmode" 703)
(setq pt2 (getpoint pt1 "\nPick second point: "))
(setvar "osmode" oldos)
(setq ang (angle pt1 pt2))
(setq dist (/ (distance pt1 pt2) 2.0))
(setq pt3(polar pt1 ang dist))
(command "dimm96" pt3)
)

the command dimm96 comes from this
Code: [Select]
;sets dimension from the mid of 2 selected points to the mid of 2 selected points
(DEFUN C:dimmid()
(setq oldos (getvar "osmode"))
(setvar "osmode" 703)
(setq pt1 (getpoint "\nPick first point: "))
(setvar "osmode" 703)
(setq pt2 (getpoint pt1 "\nPick second point: "))
(setvar "osmode" oldos)
(setq ang (angle pt1 pt2))
(setq dist (/ (distance pt1 pt2) 2.0))
(setq pt3(polar pt1 ang dist))
(command "dimm96" pt3)
)

I'm a bit lost on how to put the two together.

danny

  • Guest
dimension from mid of two points
« Reply #1 on: March 22, 2005, 06:55:54 PM »
uuugh..
sorry this is the dimension routine..
Code: [Select]
;Sets dimension to 1/8" scale
(defun c:dimm96 ()
 (setq oldcmdecho (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (setq lyr(tblsearch "layer" "a-anno-dims"))
 (if(= lyr nil)
 (progn
 (command "-layer" "m" "a-anno-dims" "c" "g" "" "")))
 (command "clayer" "a-anno-dims")
 (princ)
  (command "units" "4" "" "" "" "" "")
  (setq dstl(tblsearch "dimstyle" "m96"))
  (if(= dstl nil)
  (progn
  (command "insert" "c:/2004cadmenu/blocks/m96.dwg" ^c)))
  (command "dimstyle" "r" "m96")
  (setvar "cmdecho" oldcmdecho)
  (command "dimlinear")
  (princ)
)
:oops:

CADaver

  • Guest
dimension from mid of two points
« Reply #2 on: March 22, 2005, 07:18:19 PM »
Make a button that has this
Code: [Select]
_non;'cal (cur + cur)/2;

That button will then act like an osnap that finds the midpoint between two other osnaped points.

For further discussion see HERE

danny

  • Guest
dimension from mid of two points
« Reply #3 on: March 22, 2005, 07:54:05 PM »
CADaver,
that calculated the mid point but kicked me out of the command I was in.
Code: [Select]
Command: l LINE Specify first point: *Cancel*

Command:
Command: _non
-layer
Current layer:  "a-anno-dims"
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/PStyle/Freeze/Thaw/LOck/Unlock/s
tAte]: on
Enter name list of layer(s) to turn on:
aflno,aflsy,afldi,a-anno-text,leader,a-anno-dims,a-anno-titl,r* Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/PStyle/Freeze/Thaw/LOck/Unlock/s
tAte]:
Command:
Command: 'cal >> Expression: (cur + cur)/2
>> Enter a point:
>> Enter a point:
(0.0 5.0 0.0)

seems to be a comflict...

CADaver

  • Guest
dimension from mid of two points
« Reply #4 on: March 22, 2005, 07:58:45 PM »
Quote from: danny
CADaver,
that calculated the mid point but kicked me out of the command I was in.
Code: [Select]
Command: l LINE Specify first point: *Cancel*
Did you place ^c^c in front of the code I posted?? If so, take it out.

danny

  • Guest
dimension from mid of two points
« Reply #5 on: March 22, 2005, 08:17:47 PM »
much mahalo's......works great.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
dimension from mid of two points
« Reply #6 on: March 22, 2005, 08:34:52 PM »
Which version of Autocad are you using ?

What about the Acad Snap Option Mid Between 2 Points

Specify next point or [Close/Undo]: _m2p  First point of mid: Second point of mid:
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

danny

  • Guest
dimension from mid of two points
« Reply #7 on: March 22, 2005, 08:47:17 PM »
I'm using ACAD2004.  tried _m2p but doesn't work.  Probably does in a later version.

SMadsen

  • Guest
Re: dimension from mid of two points
« Reply #8 on: March 23, 2005, 06:38:26 AM »
Quote from: danny

I have this as a start, but I get nil.

You should also get an "unknown command" error. Commands defined by AutoLISP cannot be called with the COMMAND function. The correct syntax for calling C:DIMM96 would be (C:DIMM96). It can't involve parameters for subcommands. So if you want to call C:DIMM96 as a command and still call it using a point parameter from another function, you'd have to arrange it in another way. For example,

Code: [Select]

(defun C:dimmid (/ pt)
  ...
  (dimm96 pt)
)

(defun dimm96 (pt)
  ...
  (if (not pt)(setq pt (getpoint "some point: ")))
  ...
)

(defun C:DIMM96 ()
  (dimm96 nil)
)

CADaver

  • Guest
dimension from mid of two points
« Reply #9 on: March 23, 2005, 09:24:54 AM »
Quote from: danny
much mahalo's......works great.
Your welcome.  If you look back at my first post, theres a link (the word "HERE" in blue) to a thread that has several options for finding a midpoint.  I like the CAl option because it's returns a true 3D midpoint.  If one point is at 0,0,0 and the other is at 10,20,30 the midpoint returned is 5,10,15.