Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

"UCS" "Plan" then move the UCS to the front of all entities in model space.

4 REPLIES 4
Reply
Message 1 of 5
kpennell
399 Views, 4 Replies

"UCS" "Plan" then move the UCS to the front of all entities in model space.

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

4 REPLIES 4
Message 2 of 5
Kent1Cooper
in reply to: kpennell


@kpennell wrote:

....

Is there a "LowerCorner" and an "UpperCorner" for all entities.  ....


EXTMIN & EXTMAX

Kent Cooper, AIA
Message 3 of 5
kpennell
in reply to: Kent1Cooper

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

Message 4 of 5
kpennell
in reply to: kpennell

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.

Message 5 of 5
Kent1Cooper
in reply to: kpennell


@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....

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost