Message 1 of 6
Internal Validation error when Moving Components within components

Not applicable
05-02-2016
11:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have code that aligns a set of components that are contained within a greater component to a different components origin. I get a InternalValidation error: XL::Utils::getObjectPath(pBody,objPath,nullPtr,compPath). Error.
Its not clear to me why this happens, as the same moving code works for a component with no sub components. Does someone know what causes this error and how to fix/avoid it?
Here is a sample program that creates the error. Start it in a design with some other component ("Component1") that does not have the default origin.
#Author- #Description- import adsk.core, adsk.fusion, adsk.cam, traceback def createNewComponent(rootComp): allOccs = rootComp.occurrences newOcc = allOccs.addNewComponent(adsk.core.Matrix3D.create()) return newOcc.component def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface product = app.activeProduct design = adsk.fusion.Design.cast(product) rootComp = design.rootComponent comp1 = design.allComponents.itemByName("Component1") comp2 = createNewComponent(rootComp) comp3= createNewComponent(comp2) sketches = comp3.sketches sketch = sketches.add(comp3.xZConstructionPlane) center = comp3.originConstructionPoint.geometry sketch.sketchCurves.sketchCircles.addByCenterRadius(center,4) extrudes = comp3.features.extrudeFeatures prof = sketch.profiles[0] extInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation) distance = adsk.core.ValueInput.createByReal(3) extInput.setDistanceExtent(False, distance) extrudes.add(extInput) features = comp2.features entities = adsk.core.ObjectCollection.create() for body in comp3.bRepBodies: entities.add(body) # Create a transform to do move occs = design.rootComponent.allOccurrencesByComponent(comp1) occ = occs.item(0) origin = comp1.originConstructionPoint.createForAssemblyContext(occ) occs = design.rootComponent.allOccurrencesByComponent(comp2) occ = occs.item(0) partnerOrigin = comp2.originConstructionPoint.createForAssemblyContext(occ) ui.messageBox("My origin: "+str(origin.geometry.asArray())+"\nPartner Origin: "+str(partnerOrigin.geometry.asArray())) try: vector = partnerOrigin.geometry.vectorTo(origin.geometry) ui.messageBox("Translation vector: "+str(vector.asArray())) transform = adsk.core.Matrix3D.create() transform.translation = vector moveFeats = features.moveFeatures moveFeatureInput = moveFeats.createInput(entities, transform) moveFeats.add(moveFeatureInput) except: ui.messageBox('Move Failed: {}'.format(traceback.format_exc())) pass#Check if there is unexpected, but should handle case where there is no needed movement if design.snapshots.hasPendingSnapshot: design.snapshots.add() except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))