set visibility/lightbulb of the Joints true/false

set visibility/lightbulb of the Joints true/false

Anonymous
693 Views
2 Replies
Message 1 of 3

set visibility/lightbulb of the Joints true/false

Anonymous
Not applicable

Hi all,

I tried to use an AddIn to show me all Joints and added to the Inputs a ButtonRowCommandInput with a Show/Hide button. Then I used the OnInputChangedHandler to toggle the visibility of the Joints and the Joints-folder to true or false, depending on wich button I pressed.

I put the code to set the isLightBulbOn and isVisible in a function, which gets called and executed as desired.

def set_visibility(boolVal):
    '''
    sets the Visibility of all Joints to the committed boolValue
    '''
    #
    #print(boolVal)	#testing for debug
    #
    app = adsk.core.Application.get()
    design = adsk.fusion.Design.cast(app.activeProduct)
    root = design.rootComponent

    des_Join = root.joints
    root.isJointsFolderLightBulbOn = boolVal
    ###
    allJoints = root.allJoints
    for joint in allJoints:
        joint.isLightBulbOn = boolVal
        joint.isVisible = boolVal

 

The result is that the lightbulb-icons of all Joints and the Joints-folder as programmed switch on or off, but switch back again, so effectively nothing changed.

 

Can anybody tell me where my fault is?

 

0 Likes
Accepted solutions (1)
694 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor

Hi @Anonymous .

 

I tried creating a simple test script and I didn't notice any problems with the set_visibility function.

 

I've had experience with the InputChangedEvent being called multiple times when something changes.


How about setting up a breakpoint in InputChangedHandler to see if the set_visibility function is being called at a timing you are not expecting?

0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

I tried it with breakpoints, the handler is getting called right.

I solved the problem by using a function that handles the preview of the model. After using this function the model view gets refreshed when I press a button, and the visibility of the joints stay on/off.