Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am trying to add a move feature in conjunction with a base feature and I have something fundamentally wrong with my code. I don't know if this is possible to do or not. Can someone tell me if this is possible or not and how I would go about achieving this. Ultimately the base feature will contain more than just a single move feature. The example is just an attempt to work out the code.
Thanks in advance.
Eric
def moveBody_BF(body,x,y,z):
"""This function will move a single body. x,y and z should be in cm.
"""
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
rootComp = design.rootComponent
baseFeats = rootComp.features.baseFeatures
baseFeat = baseFeats.add()
baseFeat.startEdit()
inputEnts = adsk.core.ObjectCollection.create()
inputEnts.add(body)
#create the Matrix3D
mat = adsk.core.Matrix3D.create()
#define the vector
vector = adsk.core.Vector3D.create(x, y, z)
mat.translation = vector
#make the move
moveFeatures = baseFeat.parentComponent.features.moveFeatures
input = moveFeatures.createInput(inputEnts, mat)
input.targetBaseFeature = baseFeat
moveFeature = moveFeatures.add(input)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
app = adsk.core.Application.get()
ui = app.userInterface
#Select body
body = ui.selectEntity('Select a body', 'Bodies').entity
#define the distances to move
x=20.00*2.54;y=0.00*2.54;z=0.00*2.54
#move body
moveBody_BF(body,x,y,z)
Solved! Go to Solution.