VvierA Posted November 13, 2013 Share Posted November 13, 2013 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 Quote Link to comment
DeSignature Posted November 13, 2013 Share Posted November 13, 2013 Have you tried: (...) Act_Scale := GetLScale (ActLayer); (...) where Act_Scale is a REAL-type variable Quote Link to comment
VvierA Posted November 13, 2013 Author Share Posted November 13, 2013 Thank you very much. It works. Didn't know that this is so easy. VvierA Quote Link to comment
Vectorworks, Inc Employee klinzey Posted November 13, 2013 Vectorworks, Inc Employee Share Posted November 13, 2013 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. Quote Link to comment
VvierA Posted November 13, 2013 Author Share Posted November 13, 2013 Ok thank you for the warning. Do you know a simple routine on how to go backwards checking the parents until I reach the 'end' of the parents? How do I know how many parents an object has? VvierA Quote Link to comment
Vectorworks, Inc Employee Matt Panzer Posted November 13, 2013 Vectorworks, Inc Employee Share Posted November 13, 2013 (edited) 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 November 13, 2013 by Matt Panzer Quote Link to comment
VvierA Posted November 13, 2013 Author Share Posted November 13, 2013 Thank you Matt. The strange thing is: I used this to get the top parent of a PIO in a viewport annotation and the result is 11 (group). The next parent is type 0. Very strange, isn't it. Quote Link to comment
Vectorworks, Inc Employee klinzey Posted November 13, 2013 Vectorworks, Inc Employee Share Posted November 13, 2013 That is correct. Form inside a VP the top level will be a group. Use GetVPGroupParent() to get the parent VP of the group. Quote Link to comment
VvierA Posted November 14, 2013 Author Share Posted November 14, 2013 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)? Quote Link to comment
Vectorworks, Inc Employee Matt Panzer Posted November 14, 2013 Vectorworks, Inc Employee Share Posted November 14, 2013 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; ------------------------------------------------- Quote Link to comment
Recommended Posts
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.