Hey all,
I have code that will set and sae a current UCS to the front of an entity, of course, depending on the viewpoint. This is so, becasue we need all draft lines in front of 3D solids, such as dimensions, leaders for labels, text entities and so on (the reason for not putting these entities in paper space is another discussion :)).
But I'll have on of two problems on numerous occations:
1. The user forgets all together to run the command.
2. The user will pick the wrong entity that is in the foremost position in that view.
The code I have utilizes the following:
(setq ent (car (entsel)))
(vl-load-com)
(setq obj (vlax-ename->vla-object ent))
(vla-getboundingbox obj 'LowerCorner 'UpperCorner)
(setq LowerC (vlax-safearray->list LowerCorner))
(setq UpperC (vlax-safearray->list UpperCorner))
Then I'll analyze the X, Y and Z of both the lower and upper corners, and set my UCS to whatever is proper.
Is there a "LowerCorner" and an "UpperCorner" for all entities. I can't see "VSMIN" and VSMAX" working because the elevation of the returned coordinates is always "0,0"
Hope this makes sense,
Thanks
KP
Thanks KC
So the returned values are dependant on the view and the UCS, so I'll have to use the "Trans" function.
I'll post what I develop
KP
I just stumbled on something. What if the view is not parrellel to the X, Y and Z axis? The values retuned using "EXTMIN" and "EXTMAX" is no good now.
@kpennell wrote:I just stumbled on something. What if the view is not parrellel to the X, Y and Z axis? The values retuned using "EXTMIN" and "EXTMAX" is no good now.
I think it should still work. You should be able to set your new UCS a little above the higher [in current-CS terms] of the Z coordinates that the Extents variables return:
(command
"_.ucs" "_new"
(list
0 0 ; X & Y
(+ ; Z coordinate higher than
(max ; uppermost Z of extents in current CS [could be either, depending on view direction]
(caddr (trans (getvar 'extmin) 0 1))
(caddr (trans (getvar 'extmax) 0 1))
); max
0.1 ; by whatever amount you prefer to be above everything
); +
); list
); command
But I haven't tested it fully....