Message 1 of 6
Error with Rectangular Pattern on Inserted Component
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I was about to ask for help with my code, because i kept getting this error message
and i could remove it by editing the feature (rectangular pattern) and then immediately clicking ok
But then it occurred to me that maybe it's the same problem as in my previous post ->
that there is a problem with inserted components, so insted of making the pattern from the inserted component, i used (the "hack"/solution Jorge_Jaramillo suggested as a solution in my previous post) the parent component that i created for the inserted component and that fixed the error
Here is the code
app = adsk.core.Application.get()
ui = app.userInterface
des = adsk.fusion.Design.cast(app.activeProduct)
root = adsk.fusion.Component.cast(des.rootComponent)
#Select a face to make sketch on
face = ui.selectEntity("Select a Planar Face", "PlanarFaces").entity
#Make sketch on selected face
sketch = root.sketches.add(face)
#Add line
lines = sketch.sketchCurves.sketchLines
line = lines.addByTwoPoints(adsk.core.Point3D.create(0, 0, 0), adsk.core.Point3D.create(0, 200, 0))
#Add a sketch point a distance from each end
points = sketch.sketchPoints
sketchPoint = points.add(adsk.core.Point3D.create(0, 10, 0))
#Find components
exampleComponent = app.data.activeHub.dataProjects.item(0).rootFolder.dataFolders.itemByName("Autodesk Example").dataFiles.item(0)
#Insert Components (Using forum hack https://forums.autodesk.com/t5/fusion-api-and-scripts/rigid-joint-between-an-external-inserted-component-and-a-sketch/td-p/12941821)
instantiate = root.occurrences
forumHack = instantiate.addNewComponent(adsk.core.Matrix3D.create())
instantiateComponent = forumHack.component.occurrences.addByInsert(exampleComponent, adsk.core.Matrix3D.create(), True)
instantiateComponent.isGroundToParent = True
#Get origin points
originComponent = forumHack.component.originConstructionPoint
#Create joint geometry
joints = root.joints
jointPointComponent = adsk.fusion.JointGeometry.createByPoint(originComponent)
jointPointSketch = adsk.fusion.JointGeometry.createByPoint(sketchPoint)
joint = joints.createInput(jointPointComponent, jointPointSketch)
#Joint settings
joint.isFlipped = False
joint.setAsRigidJointMotion()
#Create joints
joints.add(joint)
#Rectrangular pattern inputs
rectangularPatternComponents = adsk.core.ObjectCollection.create()
##### ---->> This will create the error <<----- #####
#rectangularPatternComponents.add(forumHack) # This works
rectangularPatternComponents.add(instantiateComponent) # This doesn't
componentAmount = adsk.core.ValueInput.createByString('3')
patternDistance = adsk.core.ValueInput.createByString("500")
patternDistType = adsk.fusion.PatternDistanceType.ExtentPatternDistanceType
#Create rectangular pattern
rectangularPattern = root.features.rectangularPatternFeatures
rectangularPatternInput = rectangularPattern.createInput(rectangularPatternComponents, line, componentAmount, patternDistance, patternDistType)
rectangularPatternInput.setDirectionTwo(line, adsk.core.ValueInput.createByString('1'), adsk.core.ValueInput.createByString('0 mm'))
rectangularPattern.add(rectangularPatternInput)
maybe i'm doing something wrong?
if not how do i report this bug?
thanks in advance