- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I have a small problem when using the ScaleFeature. I want to iterate through all the bodies and then scale them non-uniformly. The point from which I want to scale should always be the origin of the component of the body. However, I have the problem that the bodies are scaled as I want but as soon as the ScaleFeature is executed the bodies move. I think it is either because of my declaration of the origin or because the scaleFeuture.add(...) does more than it should.🤔 But unfortunately, I'm not getting any smarter from this.
I am very grateful for any help and advice!
I have attached the culprit, maybe someone has the time and inclination to look over it!
Kind regards from Leipzig, Germany😊
import adsk.core
import adsk.fusion
import traceback
def run(context):
ui = None
try:
app: adsk.core.Application = adsk.core.Application.get()
ui = app.userInterface
design: adsk.fusion.Design = app.activeProduct
design.designType = adsk.fusion.DesignTypes.ParametricDesignType
rootComp: adsk.fusion.Component = design.rootComponent
for i in range(0, rootComp.allOccurrences.count):
occ = rootComp.allOccurrences.item(i)
# Get the associated component.
comp = occ.component
# iterate over bodies
for j in range(0, comp.bRepBodies.count):
bodies: adsk.core.ObjectCollection = adsk.core.ObjectCollection.create()
bodies.clear()
body = comp.bRepBodies.item(j)
body = body.createForAssemblyContext(occ)
bodies.add(body)
scalePoint = comp.originConstructionPoint.createForAssemblyContext(occ)
ui.messageBox(str(scalePoint.geometry.asArray()))
scaleFactor = adsk.core.ValueInput.createByReal(0.5)
scaleFeatures = rootComp.features.scaleFeatures
xScale = adsk.core.ValueInput.createByReal(float(1.55))
yScale = adsk.core.ValueInput.createByReal(float(1.45))
zScale = adsk.core.ValueInput.createByReal(float(1.35))
input = scaleFeatures.createInput(bodies, scalePoint, scaleFactor)
input.setToNonUniform(xScale, yScale, zScale)
scaleFeature = scaleFeatures.add(input)
ui.messageBox(str(scalePoint.geometry.asArray()))
Solved! Go to Solution.