RuntimeError: 2 : InternalValidationError : Utils::getObjectPath(entity, objPath, occ, contextPath)

RuntimeError: 2 : InternalValidationError : Utils::getObjectPath(entity, objPath, occ, contextPath)

corbin2
Enthusiast Enthusiast
556 Views
2 Replies
Message 1 of 3

RuntimeError: 2 : InternalValidationError : Utils::getObjectPath(entity, objPath, occ, contextPath)

corbin2
Enthusiast
Enthusiast

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:

Screenshot 2025-10-07 at 8.23.59 PM.png

 

 

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

 

 

 

 

0 Likes
Accepted solutions (1)
557 Views
2 Replies
Replies (2)
Message 2 of 3

corbin2
Enthusiast
Enthusiast

I should add some more context:

* Accessing a SketchCurve through the ProfileLoop seems to loose the assemblyContext

        curve = sketch.profiles[0].profileLoops[0].profileCurves[0].sketchEntity

 ...but the sketchEntity doesn't have a createForAssemblyContext.

If I were to find the curve in the sketch.sketchCurves, then it would work.. It just seems super slow to have to do this (like O (n squared))

 

Corbin

0 Likes
Message 3 of 3

corbin2
Enthusiast
Enthusiast
Accepted solution

...I just realized the subclasses, ie: SketchLine, have createForAssemblyContext. Seems strange to loose the context when accessing the Profiles from a Sketch but not the sketchCurves. Ah well, I can work around this!

0 Likes