Hi,
I wrote a very basic routine that I want to smarten up, but I'm out of my depth with Lisp knowledge.
I want to be able to set a ucs in 3d space by selecting the following 3 points and setting them to variables:
1. insertion point of 1st block [ucs origin point]
2. insertion point of 2nd block (same block, different location in 3d space) [ucs +ve X point]
3. centre of top of 1st block [ucs +ve Y point]
Then I would like to use the third point as a start point for an arc that is put between the two block's top centre points.
My routine is below.
The crude, badly tabbed lines with comments are mine, the 'normal'-looking lisp bit in the middle is from a bloke named BearDyugin from a CadTutor forum post.
I'm far to green too come up with lisp code like that (so far).
When I run it, the first prompt waits for me to select, but upon clicking the insertion point of my first block, it jumps over the selection of the other two points and crashes and burns with the eloquence of a fiery wall of disintegrating fuselage.
Code:
(defun C:ZAT (/ osm flag orig orix oriy)
;(setvar "clayer" "E-LTNG-MODL-ZONE-VRTX") ;SET CORRECT LAYER AS CURRENT
(command "._ucs" "_w") ;SET WORLD UCS (IF Z LEVEL CORRECT)
;(command "._ucs" "_named" "_restore" "GROUND") ;SET CUSTOM Z LEVEL UCS
(setvar "SELECTIONCYCLING" -2)
(vl-load-com)
(setq osm (getvar 'OSMODE)
flag T
)
(vl-catch-all-apply
(function
(lambda ()
(setvar 'OSMODE 64)
(while flag
(setq orig (getpoint "\nPick 0,0,0 Point <Exit>:")
)
(cond
((not orig)
(setq flag nil
orig nil
)
)
((ssget orig) (setq flag nil))
(t (princ "\nMissed 1st AT Insertion Point"))
)
)
)
)
)
; orig
(vl-catch-all-apply
(function
(lambda ()
(setvar 'OSMODE 64)
(while flag
(setq orix (getpoint "\nPick +ve X Point <Exit>:")
)
(cond
((not orix)
(setq flag nil
orix nil
)
)
((ssget orix) (setq flag nil))
(t (princ "\nMissed 2nd AT Insertion Point"))
)
)
)
)
)
; orix
(vl-catch-all-apply
(function
(lambda ()
(setvar 'OSMODE 4)
(while flag
(setq oriy (getpoint "\nPick +ve Y Point <Exit>:")
)
(cond
((not oriy)
(setq flag nil
oriy nil
)
)
((ssget oriy) (setq flag nil))
(t (princ "\nMissed 1st AT Top Centre Point"))
)
)
)
)
)
; oriy
(command "._ucs" "_3" "_none" orig "_none" orix "_none" oriy) ;CREATE TEMPORARY UCS BETWEEN FINIAL BLOCKS
(command "._arc" oriy "_e" "_cen" pause "_r" "20000") ;SCRIBE ARC BETWEEN FINIAL BLOCKS - PLI
(command "._ucs" "_w") ;RESET WORLD UCS (IF Z LEVEL CORRECT)
;(command "._ucs" "_named" "_restore" "GROUND") ;RESET CUSTOM Z LEVEL UCS
(command "._regenall") ;REGEN ALL
(command "._move" "_last" "" "_none" '(0 0 0) "_none" (list 0 0 8) ) ;FUDGE-FACTOR MOVE ARC TO TIP OF FINIAL
(setvar "SELECTIONCYCLING" 2)
(princ)
)