[S8369] Script for performing Boolean operations by specifying part names in the Geometry Editor

 

The following is an example of a script that performs Boolean operations on specified parts using the Geometry Editor.

※Since SetPropertyByReference() does not allow you to specify the part name directly, you need to convert the data type and create a Reference type that can be specified.

app = designer.GetApplication()

geomApp = app.CreateGeometryEditor()

# Extract Item type data from part name (“test1” and “test2” are part names)

partA = geomApp.GetDocument().GetAssembly().GetItem(u"test1")

partB = geomApp.GetDocument().GetAssembly().GetItem(u"test2")

# Creating reference type data from item type data

refpart1 = geomApp.GetDocument().CreateReferenceFromItem(partA)

refpart2 = geomApp.GetDocument().CreateReferenceFromItem(partB)

# Create a Boolean feature

bln = geomApp.GetDocument().GetAssembly().CreateBoolean()

# Select Boolean type such as "Subtraction" and "Union"

bln.SetProperty(u"BooleanType", 1)

# Registering parts for Target 1

bln.SetPropertyByReference(u"Part1", refpart1)

# Registering parts for Target 2

bln.SetPropertyByReference(u"Part2", refpart2)

How to use script file

Use the JMAG Script Library after reading and agreeing to the following terms of use.