InternalValidationError using Projection and Intersection

InternalValidationError using Projection and Intersection

jss.mlls
Contributor Contributor
672 Views
2 Replies
Message 1 of 3

InternalValidationError using Projection and Intersection

jss.mlls
Contributor
Contributor

Hello,

 

I am trying to get the profile of an array of components into a single sketch using the API. I have tried several methods and have run into the same 'Internal Validation' error and would like some help:

 

I have these components arranged below:

jssmlls_0-1689086453987.png

This is the end result I am trying to achieve, which I did here by projecting to a sketch in the GUI:

jssmlls_1-1689086549509.png

 

The height of the sketch is irrelevant to me. The first method I tried is to simply make a new plane, add a sketch to the plane, and project the top face to the sketch:

 

rootComp = design.rootComponent
sketches = rootComp.sketches
planes = rootComp.constructionPlanes
planeInput = planes.createInput()
offsetValue = adsk.core.ValueInput.createByReal(sliceThickness*5)# actual offset value is arbitrary
planeInput.setByOffset(rootComp.xZConstructionPlane, offsetValue)
# makes a new plane out of the plane inputs. Returns this plane
plane = planes.add(planeInput)
# add a sketch to this new plane
newLayerSketch = sketches.add(plane)
# get sketch intersections
for c in design.allComponents:
    # dont want to include original component in this projection
    if c.name != rootComp.name:
        capFace = c.features.extrudeFeatures.item(0).endFaces.item(0)
        newLayerSketch.project(capFace)

 

I get this internal validation error:

jssmlls_2-1689086954318.png

text: 

"""

Failed:

Traceback (most recent call last):

File "C:/Users/jssml/Documents/Layer Print/sw/gitPull/layerprint/fusion360/Slice/Slice.py", line 31, in run

writeDXF(datamanag[sysData.WRITEPATH], datamanag[sysData.WRITENAME], design, sliceThickness)

File "C:/Users/jssml/Documents/Layer Print/sw/gitPull/layerprint/fusion360/Slice/Slice.py", line 382, in writeDXF

newLayerSketch.project(capFace)

File "C:\Users/jssml/AppData/Local/Autodesk/webdeploy/production/dbacedcc6dabacdc41406088a765962c5f1923ad/Api/Python/packages\adsk\fusion.py", line 39128, in project

return _fusion.Sketch_project(self, entity)

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

"""

 

After not being able to deduce the issue, I tried several other methods of achieving the same result:

 

  • Projecting the body to the sketch and not the face
  • creating a plane in the middle of the thickness of the components and generating an intersection sketch with this plane and all the components shown
    • Trying this with the component objects and the bodies of the components
  • Including the rootComponent in the projections and intersections, even though I want the rootComponent excluded from the final sketch

These all result in the same validation problem, always at the line where I am trying to add the profile of these components to the sketch, whether that is via the intersection or projection method. Looking at multiple other InternalValidationError posts, they seem to be related to a potential bug in Fusion. Hard to tell how related this is.

 

I am sure there are multiple other ways to do what I want, which I am more than willing to try. Just want to see if there is nothing obvious I am doing wrong here that generates this error that can be easily remedied first. 

 

Thanks

Jesse

 

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

kandennti
Mentor
Mentor
Accepted solution

Hi @jss.mlls -San.

 

I haven't tried it, but I suspect it is the same proxy issue as described here.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/getting-point-location-after-transform/m-p... 

 

Elements within an occurrence must always be proxy.

・・・
        for c in design.allComponents:
            # dont want to include original component in this projection
            if c.name != rootComp.name:
                capFace = c.features.extrudeFeatures.item(0).endFaces.item(0)
                capFace = capFace.createForAssemblyContext(c) # proxy
                newLayerSketch.project(capFace)
・・・

 

0 Likes
Message 3 of 3

jss.mlls
Contributor
Contributor

Hi @kandennti,

 

Yes using a proxy of the occurrence of the component fixed the issue. Thanks for the help.

 

Final functioning block for anyone with a similar issue in the future:

 

    for c in design.allComponents:
        # dont want to include original component in this slice
        if c.name != rootComp.name:
            occ = rootComp.allOccurrencesByComponent(c)[0]
            capFace = c.features.extrudeFeatures.item(0).endFaces.item(0)
            capFace = capFace.createForAssemblyContext(occ) # proxy
            newLayerSketch.project(capFace)

 

Much appreciated.