creating rectangle by two points Internal validation error

creating rectangle by two points Internal validation error

Anonymous
Not applicable
877 Views
1 Reply
Message 1 of 2

creating rectangle by two points Internal validation error

Anonymous
Not applicable

I'm creating a script which generates a bounding box around a set of bodies. Once I have the BoundingBox3D object I start creating a rectangular sketch in the xz plane. I project construction points from the min and max point onto this plane and try to create a rectangle by the new sketch points. I get an error after the projected sketchPoints are created and during creation of the 2 point rectangle. What could be causing this?

Code and error below: 

occ = smartGeometry.design.rootComponent.allOccurrencesByComponent(smartGeometry.component).item(0)
        base = smartGeometry.component.features.baseFeatures.add()
        base.startEdit()
        minPointInput = smartGeometry.component.constructionPoints.createInput(occ)
        minPointInput.setByPoint(boundingBox.minPoint)
        minPoint = smartGeometry.component.constructionPoints.add(minPointInput)
        maxPointInput = smartGeometry.component.constructionPoints.createInput(occ)
        maxPointInput.setByPoint(boundingBox.maxPoint)
        maxPoint = smartGeometry.component.constructionPoints.add(maxPointInput)
        base.finishEdit()
        lowerPlaneInput = smartGeometry.component.constructionPlanes.createInput(occ)
        lowerPlaneInput.setByOffset(smartGeometry.component.xZConstructionPlane, adsk.core.ValueInput.createByReal(minPoint.geometry.y))
        lowerPlane = smartGeometry.component.constructionPlanes.add(lowerPlaneInput)
        sketch = smartGeometry.component.sketches.add(lowerPlane)
        minP = sketch.project(minPoint)
        maxP = sketch.project(maxPoint)
        sketch.sketchCurves.sketchLines.addTwoPointRectangle(minP, maxP)
        extrudes = smartGeometry.component.features.extrudeFeatures
        prof = sketch.profiles[0]
        extInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        distanceExtent = adsk.fusion.DistanceExtentDefinition.create(adsk.core.ValueInput.createByReal(maxPoint.geometry.y-minPoint.geometry.y))
        extInput.setOneSideExtent(distanceExtent, adsk.fusion.ExtentDirections.PositiveExtentDirection)
        return extrudes.add(extInput)

runtimError.PNG

0 Likes
878 Views
1 Reply
Reply (1)
Message 2 of 2

KrisKaplan
Autodesk
Autodesk

The problem is that Sketch.project returns an ObjectCollection, but SketchLines.addTwoPointRectangle takes either a Point3D or a SketchPoint.  The following change should make your code work.

 

minP = sketch.project(minPoint).item(0)
maxP = sketch.project(maxPoint).item(0)

The message in the error exception could be more informative (it is basically saying (in internal speak) that it failed to convert the pointOne argument to a geometric point).  I'll look into that.

 

Kris



Kris Kaplan
0 Likes