Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

JointOrigin rename

13 REPLIES 13
Reply
Message 1 of 14
MichaelT_123
695 Views, 13 Replies

JointOrigin rename

Hi TF360 and others in the know,

Are there any restrictions put on the naming convention of JointOrigin?

The simple code (ran in DM mode):

jointOrigin.name = newName
produces:
  File "C:/Users/MichaelT/AppData/Local/Autodesk/webdeploy/production/XXX/Api/Python/packages\adsk\fusion.py", line 20405, in _set_name
    return _fusion.JointOrigin__set_name(self, value)
RuntimeError: 2 : InternalValidationError : RequestProcessor::renameObject(this, jointOrigin->asset(), value)
 
Regards
MichaelT
 
 
MichaelT
13 REPLIES 13
Message 2 of 14

Hi Michael,

 

Is the component owning the Joint Origin in question an XRef Component?

If possible, can you please share the model and the script you are using.

 

Regards,

Mayank Malukani

SE - Fusion360

Message 3 of 14
kandennti
in reply to: MichaelT_123

Hi @MichaelT_123 .

 

I changed only this run function and executed it.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/show-hide-jointorigin/m-p/9793373#M11499 

def run(context):
    try:
        global _app, _ui
        _app = adsk.core.Application.get()
        _ui = _app.userInterface

        # create document
        _app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        des :adsk.fusion.Design = _app.activeProduct
        root :adsk.fusion.Component = des.rootComponent

        # --- try root ---
        # create box
        box = createBox(root, adsk.core.Point3D.create(0.0, 0.0, 0.0))

        # create jointOrigin
        jointOrigins = createJointOriginList(box, root)

        # rename jointOrigin
        for idx, jo in enumerate(jointOrigins):
            jo.name = '{}_{}_{}'.format(root.name, box.name, idx)


        # --- try occurrence ---
        # create occurrence
        matZero = adsk.core.Matrix3D.create()
        occ :adsk.fusion.Occurrence = root.occurrences.addNewComponent(matZero)

        # create box
        box = createBox(occ.component, adsk.core.Point3D.create(20.0, 0.0, 0.0))

        # create jointOrigin
        jointOrigins = createJointOriginList(box, occ.component)

        # rename jointOrigin
        for idx, jo in enumerate(jointOrigins):
            jo.name = '{}_{}_{}'.format(occ.component.name, box.name, idx)
        

        # finish
        _ui.messageBox('Done')
        
    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


It was renamed without any problems.

Message 4 of 14
MichaelT_123
in reply to: kandennti

Hi Fellows,

Thank you for reaching to help. I have found the problems. In fact, I found two of them.

The clue is in the sentence I wrote describing the problem. It is 'DM'.

I don't know if JointsOrigin related portion of F360 software is still the unfinished project, or it is closed and fully functional.

The point I want to make is that many groups of F360 elements can be targeted both in both parametric and direct modelling modes. 

It seems that JointOrigins can be created only in parametric mode. As I mentioned when creating jointOrigin, I was in DM mode. The strange thing is that the system allowed me to instantiate it. I could see it on the screen, rename it through UI, etc. It was, however, not valid F360 object, was dangling somewhere in a model structure. A document with such malformed entity crashed the whole F360 software on exit or on save,  perhaps due to a memory violation.

So, there are two problems:

- the first belongs to TF360, by allowing to create illegal jointOrigin object

- the second is obviously my stupidity, and it hurts 😫 !!!!

 

Regards

MichaelT

PS. If my diagnosis is correct and TF360 has some compassion ( I believe it has) it would be an excellent case to extend it by correcting the first problem and, in this way potentially saving another F360 user from deprecating himself.

MichaelT
Message 5 of 14
sunil.v.b
in reply to: MichaelT_123

HI @MichaelT_123 

Joint Origins are supported in Direct Modeling (DM) mode. Could you please share a screencast / video of the issue you are seeing in DM using UI?

 

Also regarding API issue you are seeing, it will be really helpful if you can share the design file and the API script, so that we can take a closer look at the problem.

 

Thanks

Sunil

Fusion Development team

Message 6 of 14
MichaelT_123
in reply to: sunil.v.b

Hi, Mr Sail.V.B.

 Unfortunately, I can't supply the script nor the design.

The problem could be replicated (or not) by creating jointOrgin in two ways:

- with baseFeature inactive

- with baseFeture active

The point of failure related to the issue is specified in my previous post.

Additionally, related error reports, with memory dumps and other valuable info might help to trace the problem.

CER_228528055

CER_228528620

 

Regards

MichaelT

MichaelT
Message 7 of 14
kandennti
in reply to: MichaelT_123

@MichaelT_123 .

 

I was able to reproduce it. Modifying the run function like this will result in an error.

def run(context):
    try:
        global _app, _ui
        _app = adsk.core.Application.get()
        _ui = _app.userInterface

        # create document
        _app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        des :adsk.fusion.Design = _app.activeProduct
        des.designType = adsk.fusion.DesignTypes.ParametricDesignType
        root :adsk.fusion.Component = des.rootComponent

        # --- try root ---
        # create box
        box = createBox(root, adsk.core.Point3D.create(0.0, 0.0, 0.0))

        # create jointOrigin
        jointOrigins = createJointOriginList(box, root)

        # Design mode change
        des.designType = adsk.fusion.DesignTypes.DirectDesignType

        # rename jointOrigin - error!!
        for idx, jo in enumerate(jointOrigins):
            jo.name = '{}_{}_{}'.format(root.name, box.name, idx)

        # finish
        _ui.messageBox('Done')
        
    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

ParametricDesignType -> create JointOrigin -> DirectDesignType (or BaseFeature) -> JointOrigin Rename

 

When I referred to the thing before switching the design mode after switching the design mode like, an error occurred.
I have experienced sketching in the past.

 

This is not mentioned in Help, but I interpret it as a specification.

Message 8 of 14
sunil.v.b
in reply to: kandennti

Hi @kandennti In the script if we rename the JO by general names say 

for idx, jo in enumerate(jointOrigins):
            jo.name = '{}_{}_{}'.format("hello", "world", idx)

then the renaming of JO works. Probably @MichaelT_123 is seeing some other issue. 

 

Thanks

Sunil

Fusion development team

Message 9 of 14
kandennti
in reply to: sunil.v.b

@sunil.v.b .

 

I didn't notice.
Thank you for pointing out the mistake.

Message 10 of 14
MichaelT_123
in reply to: sunil.v.b

So, what is your verdict Mr Sunil.V.B.?

 

  • There is a problem
  • Everything is OK
  • Probably Michael_123 has a wrong monitor?

Have you had a chance to look at the code surrounding the error message?

Have you investigated memory dumps in CER_s?

 

Regards

MichaelT

  1. For your information, I have spent some time (unnecessarily) assessing the validity of each answer.
MichaelT
Message 11 of 14
sunil.v.b
in reply to: MichaelT_123

Hi @MichaelT_123 

Surely there is a problem, its only that we are not able to reproduce it our end through UI. Looked at the CER reports as well and tried workflows around that, unfortunately not able to reproduce. We will continue with our efforts and if we find anything will let you know.

 

It will be super useful for us, if you can send us a sample model, sample script if this issue is specifically API related and a screen cast showing the issue. This will help us reproduce and debug the issue at our end.

 

Thanks

Sunil

Fusion Development team

 

 

Message 12 of 14
MichaelT_123
in reply to: sunil.v.b

Hi, Mr Sail.V.B.


OOOhhhh good to know that I am not totally wrong (stupid 😀).
As per the sample code, in anticipation of your follow-up (thank you for it) I have prepared it already. I hope that it shows where the problem occurs in its naked form.
As per the cause of the problem consider looking on C-side (the core of F360 under python skin) how jointOrigin.name string memory is allocated in the context of whole JO structure/class.

 

#Author-MichaelT
#Description-Test JointOrigin renaming problem

import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
    ui = None
    try:
        app   = adsk.core.Application.get()
        ui    = app.userInterface
        app   = adsk.core.Application.get()
        des   = adsk.fusion.Design.cast(app.activeProduct)
        ui    = app.userInterface
        root  = des.rootComponent   
        des.designType = adsk.fusion.DesignTypes.ParametricDesignType     
        # Enable/disable baseFeature of rootComponent   NO DIFFERENCE
        is_root_BF = True      #True False
        if is_root_BF:
            root_BF      = root.features.baseFeatures.add()
            root_BF.name = 'root_BF'
            root_BF.startEdit()
        else:
            root_BF = None

        occ_A  = root.occurrences.addNewComponent( adsk.core.Matrix3D.create() )
        comp_A = occ_A.component
        comp_A.name = 'comp_A'
        occ_A.activate()
        # Enable/disable baseFeature of comp_A      Enable=ERROR  Disable=OK
        is_comp_A_BF = True    #True False
        if is_comp_A_BF:
            comp_A_BF      = comp_A.features.baseFeatures.add()
            comp_A_BF.name = 'comp_A_BF'
            comp_A_BF.startEdit()
        else:
            comp_A_BF = None

        if( comp_A_BF ):
            sketch_A = comp_A.sketches.addToBaseOrFormFeature( comp_A.xYConstructionPlane, comp_A_BF, False)    
        else:
            sketch_A = comp_A.sketches.add( comp_A.xYConstructionPlane, occ_A )   

        line_A             = sketch_A.sketchCurves.sketchLines.addByTwoPoints( sketch_A.originPoint,  adsk.core.Point3D.create(1,0,0) )
        jointOrigins       = comp_A.jointOrigins
        jointGeometry      = adsk.fusion.JointGeometry.createByCurve( line_A, adsk.fusion.JointKeyPointTypes.StartKeyPoint ) 
        jointOriginInput   = jointOrigins.createInput(jointGeometry)
        jointOrigin_A      = jointOrigins.add(jointOriginInput)    
        # Rename jointOrigin_A
        isRename           = True
        if isRename:
            jointOrigin_A.name = 'jointOrigin_A'    

        if( comp_A_BF ):
            comp_A_BF.finishEdit()
        if( root_BF ):
            root_BF.finishEdit()      

        des.activateRootComponent()      

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


Regards
MichaelT

MichaelT
Tags (3)
Message 13 of 14
sunil.v.b
in reply to: MichaelT_123

Thank you @MichaelT_123 for sharing the sample script. In this API script New component and Joint origin is being created in Base Feature Active mode (startEdit()). However, in Base Feature Acitive mode, we cannot create a New Component and also Joint Origin; in general assemble commands are not available in Base Feature activie mode. Please see screencast video at the end showing this.

 

If the intent is to create the component, Joint origin in DM, then below code could be used (I just modified the script you shared). Later this design can be converted to Parametric design as well if needed to work in PM.

 

# modified to DirectDesignType instead of ParametricDesignType with BaseFeature
import adsk.core, adsk.fusion, traceback
def run(context):
    ui = None
    try:
        app   = adsk.core.Application.get()
        ui    = app.userInterface
        app   = adsk.core.Application.get()
        des   = adsk.fusion.Design.cast(app.activeProduct)
        ui    = app.userInterface
        root  = des.rootComponent   
        des.designType = adsk.fusion.DesignTypes.DirectDesignType

        occ_A  = root.occurrences.addNewComponent( adsk.core.Matrix3D.create() )
        comp_A = occ_A.component
        comp_A.name = 'comp_A'
        occ_A.activate()


        sketch_A = comp_A.sketches.add( comp_A.xYConstructionPlane, occ_A )   

        line_A             = sketch_A.sketchCurves.sketchLines.addByTwoPoints( sketch_A.originPoint,  adsk.core.Point3D.create(1,0,0) )
        jointOrigins       = comp_A.jointOrigins
        jointGeometry      = adsk.fusion.JointGeometry.createByCurve( line_A, adsk.fusion.JointKeyPointTypes.StartKeyPoint ) 
        jointOriginInput   = jointOrigins.createInput(jointGeometry)
        jointOrigin_A      = jointOrigins.add(jointOriginInput)    
        # Rename jointOrigin_A
        isRename           = True
        if isRename:
            jointOrigin_A.name = 'jointOrigin_A'   

        des.activateRootComponent()      

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

 

Thanks

Sunil

Message 14 of 14
MichaelT_123
in reply to: sunil.v.b

Hi, Mr Sail.V.B.

Could you please answer the following points:

  • Is the opinion you presented is final regarding the attempt to address the problem?
  • Is your opinion is the official one and supported by the Cortex of QA Spine of F360 Development Body?

Sincerely

MichaelT

MichaelT

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report