Jump to content
Developer Wiki and Function Reference Links ×

Is 2D, is 3D: sharing some infos


_c_

Recommended Posts

I noticed that my old subroutine for parsing the 3D state of an object wasn't reliable any longer. 

 

There are various object flags in the SDK (/SDKLib/Include/Kernel/API/ObjectVariables.h) that allow to parse the multiple flavours of objects' 2D-ness .

Surprisingly, though, a layer plane object doesn't resolve as 2D.

 

For me a rectangle, as primitive shape, is a 2D object, be it screen or layerPlane. And for a multitude of Vectorscript tasks this is what we need to know.

In this file you can experiment with the various flags:

test is3D.vwx

 

Example: a layer plane object surprisingly resolves as 3D with the flag 651:

 

1706463048_Screenshot2022-04-05at08_57_44.thumb.png.42c27bee1311a5d4877be07bbabf34a7.png

 

Example: a 3D plane object is not really 2D for us but surprisingly resolves as planar with the flag 1161:

(and let's not speak about the surreal fact that this object floats in space without giving a z value in the OIP, a reason for confusion for the user)

 

333143332_Screenshot2022-04-05at08_58_07.thumb.png.b8e8a95c9d797c755c379c13ccf36858.png

 

 

 

Thus:

{ *********************************************** }
{ checks if h is 3D obj, doesn't check NIL status }
FUNCTION H_Is3D(h: HANDLE): BOOLEAN;
	BEGIN
		H_Is3D := (GetObjectVariableBoolean(h, 1160) = FALSE) AND (GetObjectVariableBoolean(h, 1162) = FALSE);
		{ isScreen and isLayerPlane both false }
	END;

 

or in Python

def o_is3D(h):
	"""checks if h is 3D obj, doesn't check NIL status"""

	return ((vs.GetObjectVariableBoolean(h, 1160) == False) and (vs.GetObjectVariableBoolean(h, 1162) == False))
	# isScreen and is LayerPlane are both false

 

 

Try this on any selection:

import vs

h = vs.FSActLayer()
if h == vs.Handle(0):
	vs.AlrtDialog('Select something')
else:
	isScreen = vs.GetObjectVariableBoolean(h, 1160) # obj is screen
	isPlanar = vs.GetObjectVariableBoolean(h, 1161) # obj is planar
	isLayerPlane = vs.GetObjectVariableBoolean(h, 1162) # obj is in layer plane
	isHybrid = vs.GetObjectVariableBoolean(h, 1163) # obj is hybrid
	is3D = vs.GetObjectVariableBoolean(h, 650) # obj is 3D
	is2D = vs.GetObjectVariableBoolean(h, 651) # obj is 2D

	vs.AlrtDialog(f"screen: {isScreen}\nisPlanar: {isPlanar}\nlayerPlane: {isLayerPlane}\nhybrid: {isHybrid}\nis2D: {is2D}\nis3D: {is3D}")


 

Edited by _c_
  • Like 2
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...