PDA

View Full Version : Automation Error. UCS X and Y axis aren't perpendicular


blasto
2009-04-07, 12:08 PM
Hi,
there must be some kind of precision error in calculation of perpendicularity of x and y vectors in vlisp. I get this error when tried to run the code below to add an ucs object to the active document.
Previously VBA coders came across this error and some of them wrote very tedious and complicated solution routines that I couldn't understand as a lisp programmer.


(defun c:ucc ()
(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
(setq ucsobj (vla-get-usercoordinatesystems adoc))
(setq origin (vla-getvariable adoc "UCSORG"))
(setq xdir (vla-getvariable adoc "UCSXDIR"))
(setq ydir (vla-getvariable adoc "UCSYDIR"))
(setq ucs_current (vla-add ucsobj origin xdir ydir "UCS_Current"))
)


any ideas to overcome this error? thanks

l3ch
2009-04-08, 08:52 AM
What I don't know, and I would like it, is why when you draw a 3dline and select that line as UCS, the UCS is not aligned with the line.

dgorsman
2009-04-08, 08:48 PM
The system variables you are getting are unit vectors; I think the UCS collection Add method is expecting WCS points for the x and y directions. Try applying the x/y/z values from the unit vectors as delta's to the origin point, and make sure everything is in WCS.

blasto
2009-04-09, 08:46 AM
thanks dgorsman you made the correct diagnosis for this problem! I tought it would be unit vectors of direction but actually add method was expecting wcs points as you have said. thanks again.