Jump to content
Developer Wiki and Function Reference Links ×

Tricky? How to get the scale of a viewport annotation?


VvierA

Recommended Posts

Hello again,

with your kind help I managed to get my plugin working but now there is the next challenge as mentioned in my earlier post:

I have a plugin object that may be uses within a layer oder within a viewport annotation.

How can I check wether the PIO is inside a layer or inside a viewport annotation and how can I retrieve the scale of the viewport? (the scale of a layer is not so difficult I think)

Kind regards

VvierA

Link to comment
  • Vectorworks, Inc Employee

NOOOO......!!

Using Act_Scale:= GetLScale (ActLayer) is not a good idea.

It looks like it works especially when testing but will get you into all kinds of problems later.

This will cause the object to be the wrong scale if the object is ever regenerated when the layer is not active and you are at a different layer scale.

You need to look at the container for the object and then determine the layer scale.

To get the scale of the Viewport use:

GetObjectVariableReal(hVP, 1003)

You basically need to do a GetParent on the object till you find out what container (Layer, Symbol, Viewport, Group, Symbol, etc) you are working inside of and then get the layer scale.

The only time you use ActLayer is when there is no container, i.e. the object is just being placed.

Link to comment
  • Vectorworks, Inc Employee

You need to create a loop. Something like:

parentHandle := GetParent( pioHandle );

IF( parentHandle <> NIL ) THEN

REPEAT

????parentHandle := GetParent( parentHandle );

UNTIL

????(

????( parentHandle = NIL )

????OR

????( GetType( parentHandle ) = 31 ) {is a layer}

????OR

????( GetType( parentHandle ) = 122 ) {is a viewport}

????OR

????etc., etc...

????);

Edited by Matt Panzer
Link to comment

Ok thank you. I programmed a loop and checked the types of the parents.

If it's a viewport I get the scale with GetObjectVariableReal(hVP, 1003).

But how do I get the scale of the Layer where the PIO is nested?

May I use Act_Scale := GetLScale (ActLayer);

if I determinded that the upper most parent is a layer or is there another way to get the scale of the layer (for example another Object Variable)?

Link to comment
  • Vectorworks, Inc Employee

Before even going into the "parent checking" loop, I would test to see if the PIO's parent layer is a design layer. If it is, then all you need is the design layer's scale.

-------------------------------------------------

pioParentLayerHandle := GetLayer( pioHandle );

IF ( GetObjectVariableInt( pioParentLayerHandle, 154 ) = 1 ) { 1 = Design Layer, 2 = Sheet layer }

THEN pioParentLayerScale := GetLScale( pioParentLayerHandle )

ELSE

BEGIN

????{insert "parent checking" loop here}

END;

-------------------------------------------------

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...