Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

Having trouble with TemporaryBRepManager.createHelixWire()

Anonymous
469 Views
3 Replies
Message 1 of 4

Having trouble with TemporaryBRepManager.createHelixWire()

Anonymous
Not applicable

I am having trouble getting the createHelixWire to work.

Here is a script that should generate a Helix with:

 Oriented along the Z-axis

 starting at z=0

 pitch 0.2

 turns 10

 diameter 2

 no taper

 

But it just generates a straight vertical wire. I can't figure out what I am doing wrong.

The Helix Wire in the TemporaryBRepManager sample generates fine so it must be my fault.

 

Screenshot 2020-06-03 at 15.52.00.png

import adsk.core, adsk.fusion, adsk.cam, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        des = app.activeProduct
        root = des.rootComponent
        bodies = root.bRepBodies

        tbm = adsk.fusion.TemporaryBRepManager.get()

        hw1 = tbm.createHelixWire(
            adsk.core.Point3D.create(0,0,0),
            adsk.core.Vector3D.create(0,0,1),
            adsk.core.Point3D.create(1,0,0),
            0.5,
            10,
            0.5
        )

        bodies.add(hw1)

    except:
        print(traceback.format_exc())
Reply
Reply
0 Likes
Accepted solutions (1)
470 Views
3 Replies
Replies (3)
Message 2 of 4

kandennti
Mentor
Mentor
Accepted solution

Hi @Anonymous .

 

When using Temporary BRepManager in Parametric mode, bodies.add must be done in the base future.

It will look like this.

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        des = app.activeProduct
        root :adsk.fusion.Component = des.rootComponent
        bodies = root.bRepBodies

        tbm = adsk.fusion.TemporaryBRepManager.get()

        hw1 = tbm.createHelixWire(
            adsk.core.Point3D.create(0,0,0),
            adsk.core.Vector3D.create(0,0,1),
            adsk.core.Point3D.create(1,0,0),
            0.5,
            10,
            0.5
        )

        if des.designType == adsk.fusion.DesignTypes.ParametricDesignType:
            # Parametric mode
            baseFeatures = root.features.baseFeatures
            baseFeature = baseFeatures.add()

            baseFeature.startEdit()
            bodies.add(hw1, baseFeature)
            baseFeature.finishEdit()
        else:
            # direct mode
            bodies.add(hw1)

    except:
        print(traceback.format_exc())

The completed BRepWire Object will not be displayed correctly on the screen except for straight lines.
However, if you use it as the path of the GUI pipe command, you can confirm that you have the correct information.

1.png

 

I made use of this and created this.

https://github.com/kantoku-code/ExportWire 

Reply
Reply
2 Likes
Message 3 of 4

Anonymous
Not applicable

Thank you so much!

 

Sorry, I forgot to mention that my code only runs in direct modeling mode.

 

This had me stumped for days, and in the end, it just didn't display correctly.

For some reason, the wire created by the TemporaryBRepManager sample code does display correctly, so I thought it must be something I am doing wrong.

Reply
Reply
0 Likes
Message 4 of 4

kandennti
Mentor
Mentor

When I included it in the sketch, I was able to confirm the correct state.

 

・・・

        if des.designType == adsk.fusion.DesignTypes.ParametricDesignType:
            # Parametric mode
            baseFeatures = root.features.baseFeatures
            baseFeature = baseFeatures.add()

            baseFeature.startEdit()
            wire = bodies.add(hw1, baseFeature)
            baseFeature.finishEdit()
        else:
            # direct mode
            wire = bodies.add(hw1)
        
        skt = root.sketches.add(root.xYConstructionPlane)
        skt.include(wire.edges[0])
・・・

1.png

 

Reply
Reply
1 Like