- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi! I'm having trouble with occurrences...and getting the assemblyContext right.
I get "RuntimeError: 2 : InternalValidationError : Utils::getObjectPath(entity, objPath, occ, contextPath)" when I run the attached script.
Steps to reproduce.
1. Open the attached .f3d file
2. Activate Component2 (important)
3. Run the attach script (zipped, python, code duplicated below)
What is happening:
Given the following component hierarchy:
The script does this:
* Gets the first occurrence (Component1:1) and grabs the sketchEntity in the second sketch, named "design"
* Creates a new child component under the Component2:1 occurrence, creates a new sketch in it, and attempts to project2 the sketchEntity. But fails with the error.
Relevant code; which I think does the right thing on creating the right assembly context...but I'm not doing something right or misunderstanding how to do this. Of course...it works fine to do it "by hand" in Fusion.
# find a sketch curve
firstOcc = design.rootComponent.occurrences[0]
sketch = firstOcc.component.sketches[0]
sketch = sketch.createForAssemblyContext(firstOcc)
curve = sketch.profiles[0].profileLoops[0].profileCurves[0].sketchEntity
activeOcc: Occurrence = design.activeOccurrence
secondOcc = activeOcc.component.occurrences.addNewComponent(adsk.core.Matrix3D.create())
secondOcc = secondOcc.createForAssemblyContext(activeOcc)
newSketch = secondOcc.component.sketches.add(secondOcc.component.xYConstructionPlane)
newSketch = newSketch.createForAssemblyContext(secondOcc)
newSketch.project2([curve], True)
Any ideas?
thanks, Corbin
Solved! Go to Solution.