Jump to content
Developer Wiki and Function Reference Links ×

Wrapping marionette script breaks outputs


tomcee

Recommended Posts

Hi

 

Attached is a script to recreate our company name and logo that is font size controllable and font independent. End goal is this to be an object node.

 

The script works until I wrap the script then only the converted text objects are output and not the geometry. I think it has something to do with the "Convert To Poly Group" node as when I exclude this from the script the text and geometry work in the wrapper. Anyone have an idea what might be going on?

 

Simplified version of script attached.

 

Thanks!

Logo In Marionette v02.vwx

Link to comment

In Vectorworks scripts, there are a number of things that don't actually exist until the script finishes. Apparently the conversion of the text to poly lines is one of those things. Since the converted poly lines don't exist, the height and width of the rectangle are zero when inside the wrapper.

 

My guess is that by putting them into a group it "forces" the calculations of the size to be completed immediately instead of waiting until the rest of the script runs.

 

But that if purely a guess on my part.  I just know that it can be very difficult to create a new object in a script and then do anything to that object in the same script because the values that you want to calculate with don't exist yet.

 

Glad you found a work around.

  • Like 1
Link to comment

This kind of behavior is quite common. Often we need a "ResetObject" or a "ResetBBox" after some commands. I would not say this is a Bug or an error because it can be smart to not reset and recalculate  everything in every single Node/Step of a script to keep it fast.

The "GroupNode" resets the BBox. Also the Geometry-Grouping of Marionette Network resets the BBox of the PolyGroup by accident.
You can reproduce the same behavior with a Script.
 

h = vs.FSActLayer()

num, polyGroup = vs.TrueTypeToPoly(h)
bbox = vs.GetBBox(polyGroup)
vs.AlrtDialog(str(bbox))
vs.ResetBBox(polyGroup)
bbox = vs.GetBBox(polyGroup)
vs.AlrtDialog(str(bbox))

 

The vs.TrueTypeToPoly() returns a group with zero size Bounding Box. We have to first reset the bbox to get the bbox size correctly.

Or in the Script:
image.thumb.png.5ad9e1e9172fe1596c2b735efaaa15e5.png

 

 

Unfortunately, resetBBox (also ResetObject which is also a common needed Node) are not part of the standard Node-Content.
 

Edited by DomC
type errors
  • Like 3
Link to comment
  • 7 months later...

Hello,

 

to get the "vs.ResetBBox(h)" function within a Marionette node you can write the node with a bit of Python code by replacing the code in any node with the code below.


@Marionette.NodeDefinition
class Params(metaclass = Marionette.OrderedClass):
#APPEARANCE
	#Name
	this = Marionette.Node( 'vs.ResetBBox(h)' )
	this.SetDescription( 'vs.ResetBBox(h)' )

	#Input Ports
	x = Marionette.PortIn( vs.Handle(0), 'h' )
	x.SetDescription( "input" )

	#OIP Controls

	#Output Ports
	y = Marionette.PortOut('h')   
	y.SetDescription( "output" )

#BEHAVIOR
	#this.SetListAbsorb()
	
def RunNode(self):
	#inputs
	x = self.Params.x.value

	#script
	vs.ResetBBox(x)

	#outputs
	self.Params.y.value = x

 

Another way would be to create your own "node" by using the "function" node within a wrapper. Therefore you have to write the Python function "vs.ResetBBox(x)" into the OIP of the "function" node and wrap a small Marionette that looks like this:

grafik.png.ff85f086e98729ecb4b898ad256935bb.png

 

You can now use this wrapper like @DomC uses the "ResetBBox" node in his Marionette.

 

 

Regards,

Letti

 

Edited by Letti R
  • Like 1
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...