<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic RuntimeError: 2 : InternalValidationError : Utils::getObjectPath(entity, objPath, occ, contextPath) in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/runtimeerror-2-internalvalidationerror-utils-getobjectpath/m-p/13842733#M22246</link>
    <description>&lt;P&gt;Hi! I'm having trouble with occurrences...and getting the assemblyContext right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get "RuntimeError: 2 : InternalValidationError : Utils::getObjectPath(entity, objPath, occ, contextPath)" when I run the attached script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steps to reproduce.&lt;/P&gt;&lt;P&gt;1. Open the attached .f3d file&lt;/P&gt;&lt;P&gt;2. Activate Component2 (important)&lt;/P&gt;&lt;P&gt;3. Run the attach script (zipped, python, code duplicated below)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is happening:&lt;/P&gt;&lt;P&gt;Given the following component hierarchy:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-10-07 at 8.23.59 PM.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1577117i4D4007AC4D0C5D6F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2025-10-07 at 8.23.59 PM.png" alt="Screenshot 2025-10-07 at 8.23.59 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script does this:&lt;/P&gt;&lt;P&gt;* Gets the first occurrence (Component1:1) and grabs the sketchEntity in the second sketch, named "design"&lt;/P&gt;&lt;P&gt;* Creates a new child component under the Component2:1 occurrence, creates a new sketch in it, and attempts to project2 the sketchEntity. &amp;nbsp;But fails with the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;        # 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)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;thanks, Corbin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Oct 2025 03:39:39 GMT</pubDate>
    <dc:creator>corbin3</dc:creator>
    <dc:date>2025-10-08T03:39:39Z</dc:date>
    <item>
      <title>RuntimeError: 2 : InternalValidationError : Utils::getObjectPath(entity, objPath, occ, contextPath)</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/runtimeerror-2-internalvalidationerror-utils-getobjectpath/m-p/13842733#M22246</link>
      <description>&lt;P&gt;Hi! I'm having trouble with occurrences...and getting the assemblyContext right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get "RuntimeError: 2 : InternalValidationError : Utils::getObjectPath(entity, objPath, occ, contextPath)" when I run the attached script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steps to reproduce.&lt;/P&gt;&lt;P&gt;1. Open the attached .f3d file&lt;/P&gt;&lt;P&gt;2. Activate Component2 (important)&lt;/P&gt;&lt;P&gt;3. Run the attach script (zipped, python, code duplicated below)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is happening:&lt;/P&gt;&lt;P&gt;Given the following component hierarchy:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-10-07 at 8.23.59 PM.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1577117i4D4007AC4D0C5D6F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2025-10-07 at 8.23.59 PM.png" alt="Screenshot 2025-10-07 at 8.23.59 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script does this:&lt;/P&gt;&lt;P&gt;* Gets the first occurrence (Component1:1) and grabs the sketchEntity in the second sketch, named "design"&lt;/P&gt;&lt;P&gt;* Creates a new child component under the Component2:1 occurrence, creates a new sketch in it, and attempts to project2 the sketchEntity. &amp;nbsp;But fails with the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;        # 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)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;thanks, Corbin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Oct 2025 03:39:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/runtimeerror-2-internalvalidationerror-utils-getobjectpath/m-p/13842733#M22246</guid>
      <dc:creator>corbin3</dc:creator>
      <dc:date>2025-10-08T03:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: RuntimeError: 2 : InternalValidationError : Utils::getObjectPath(entity, objPath, occ, contextPath)</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/runtimeerror-2-internalvalidationerror-utils-getobjectpath/m-p/13842760#M22247</link>
      <description>&lt;P&gt;I should add some more context:&lt;/P&gt;&lt;P&gt;* Accessing a SketchCurve through the ProfileLoop seems to loose the assemblyContext&lt;/P&gt;&lt;PRE&gt;        curve = sketch.profiles[0].profileLoops[0].profileCurves[0].sketchEntity&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;...but the sketchEntity doesn't have a createForAssemblyContext.&lt;/P&gt;&lt;P&gt;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))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Corbin&lt;/P&gt;</description>
      <pubDate>Wed, 08 Oct 2025 04:16:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/runtimeerror-2-internalvalidationerror-utils-getobjectpath/m-p/13842760#M22247</guid>
      <dc:creator>corbin3</dc:creator>
      <dc:date>2025-10-08T04:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: RuntimeError: 2 : InternalValidationError : Utils::getObjectPath(entity, objPath, occ, contextPath)</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/runtimeerror-2-internalvalidationerror-utils-getobjectpath/m-p/13842764#M22248</link>
      <description>&lt;P&gt;...I just realized the subclasses, ie: SketchLine, have&amp;nbsp;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!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Oct 2025 04:32:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/runtimeerror-2-internalvalidationerror-utils-getobjectpath/m-p/13842764#M22248</guid>
      <dc:creator>corbin3</dc:creator>
      <dc:date>2025-10-08T04:32:52Z</dc:date>
    </item>
  </channel>
</rss>

