How to use MoveFeatureInput.defineAsPointToPoint

How to use MoveFeatureInput.defineAsPointToPoint

rolandas_vegis
Advocate Advocate
157 Views
1 Reply
Message 1 of 2

How to use MoveFeatureInput.defineAsPointToPoint

rolandas_vegis
Advocate
Advocate

Hello,

 

I have been trying to use the method MoveFeatureInput.defineAsPointToPoint, yet I keep getting invalid entity error. Could not find any examples how to use it.

 

I tried passing: 2 sketch points, a sketch point and vertex, 2 Point3D yet always same error.

 

So which objects are accepted here?

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

osamuETYQY
Participant
Participant

Hi, rolandas_vegis,

The following code worked for me.

 

If the point belongs to an occurrence of a sub component, you may need to do `p1.createForAssemblyContext(occurence)` when you give it to `defineAsPointToPoint`.

 

        app = adsk.core.Application.get()
        design = adsk.fusion.Design.cast(app.activeProduct)
        root = design.rootComponent
        
        sketch = root.sketches.add(root.xYConstructionPlane)
        sketch.sketchCurves.sketchCircles.addByCenterRadius(adsk.core.Point3D.create(), 1)
        cylinder = root.features.extrudeFeatures.addSimple(
            sketch.profiles[0],
            adsk.core.ValueInput.createByReal(1),
            cast(adsk.fusion.FeatureOperations, adsk.fusion.FeatureOperations.NewBodyFeatureOperation),
        )
        
        p1 = sketch.sketchPoints.add(adsk.core.Point3D.create(0, 0, 0))
        p2 = sketch.sketchPoints.add(adsk.core.Point3D.create(0, 1, 1))
        
        inp = root.features.moveFeatures.createInput2(adsk.core.ObjectCollection.createWithArray([cylinder.bodies[0]]))
        inp.defineAsPointToPoint(p1, p2)
        root.features.moveFeatures.add(inp)