TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: danny 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.
;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
;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.
-
uuugh..
sorry this is the dimension routine..
;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:
-
Make a button that has this
_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 (http://www.theswamp.org/phpBB2/viewtopic.php?t=2587&highlight=midpt)
-
CADaver,
that calculated the mid point but kicked me out of the command I was in.
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,
that calculated the mid point but kicked me out of the command I was in.
Command: l LINE Specify first point: *Cancel*
Did you place ^c^c in front of the code I posted?? If so, take it out.
-
much mahalo's......works great.
-
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:
-
I'm using ACAD2004. tried _m2p but doesn't work. Probably does in a later version.
-
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,
(defun C:dimmid (/ pt)
...
(dimm96 pt)
)
(defun dimm96 (pt)
...
(if (not pt)(setq pt (getpoint "some point: ")))
...
)
(defun C:DIMM96 ()
(dimm96 nil)
)
-
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.