Add-in not shown in "Flat Pattern"

Add-in not shown in "Flat Pattern"

Anonymous
Not applicable
705 Views
5 Replies
Message 1 of 6

Add-in not shown in "Flat Pattern"

Anonymous
Not applicable

My DXF For Laser add-in appears in the sketch menu normally, however, when in Flat Pattern view it is not displayed. I even have it pinned to the top toolbar and it is also removed in flat view. Dumping the toolbar info doesn't provide any insight - apart from flat pattern NOT having an "environment" which smells of a hack and I found an unrelated typo "SheetetalCreatePanel" (instead of SheetMetalCreatePanel).

 

Any solutions / workarounds out there?

0 Likes
706 Views
5 Replies
Replies (5)
Message 2 of 6

marshaltu
Autodesk
Autodesk

Hello,

 

I just had the addin "DXF4Laser" (version 1.1.1) in my machines and gave a quick try. Unfortunately I cannot see the menu "Save DXF for Laser Cutting" in sketch panel of both "Model" and "Sheet Metal" in my Windows machine. However it worked well in my MAC machine.

 

I did testing that the following codes worked well in both machines. Please check if something was wrong in your addin. I found the calling to set control promotion was wrong in your addin. 

 

Thanks,

Marshal

 

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

ui = None

def run(context):
    try:
        app = adsk.core.Application.get()
        global ui
        ui  = app.userInterface
        
        mycmd = ui.commandDefinitions.addButtonDefinition('MyCommand', 'My Command', '', '')
        panel = ui.allToolbarPanels.itemById('SketchPanel')
        mycontrol = panel.controls.addCommand(mycmd)
        mycontrol.isPromotedByDefault = True
        mycontrol.isPromoted = True

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

def stop(context):
    try: 
        mycmd = ui.commandDefinitions.itemById('MyCommand')
        panel = ui.allToolbarPanels.itemById('SketchPanel')
        mycontrol = panel.controls.itemById('MyCommand')
        if mycmd:
            mycmd.deleteMe()
        if mycontrol:
            mycontrol.deleteMe()

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


Marshal Tu
Fusion Developer
>
0 Likes
Message 3 of 6

Anonymous
Not applicable

I am curious as to why the add-in doesn't appear for you on windows but for the moment lets take that as a separate issue and table it for now (although if you figure it out i'd love to know).

 

The sample add-in you provided has the same behavior as my add-in, for me at least. I can see the item in the sketch menu until I go into "flat pattern" - then it's gone. When i exit flat pattern it returns. This is NOT an issue with simply being in the "Sheet Metal" environment - this is specific to the Flat Pattern "view"

K0ILc3U

 

I've written a framework to make writing add-ins less tedious so sharing my code would require a good bit of diving in and since the simple sample you shared exhibits the behavior I don't think we're at that point yet - although I'm more than willing to share my code. None the less here's a snip of my button creation.

 

In my add-in class:

  def add_button(self):
    self.remove_button()
    button = super().add_button()
    button.toolClipFilename = os.path.join(self.resource_dir, 'captions/Thumb.png')
    panel = self.ui.allToolbarPanels.itemById('SketchPanel')
    panel.controls.addCommand(button)
    button.isPromotedByDefault = True
    button.isPromoted = True
    return button

  def remove_button(self):
    button = self.ui.commandDefinitions.itemById(self.command_id)
    panel = self.ui.allToolbarPanels.itemById('SketchPanel')
    button_control = panel.controls.itemById(self.command_id)
    if button:
      button.deleteMe()
    if button_control:
      button_control.deleteMe()

And in my base class (which the above code calls via super...)

  def add_button(self):
    """Called at an appropriate time to add a button to one of Fusions menus.

    Overriders of this method should call super(), then they can add the button to the Fusion menu system if desired.
    Finally the button object must be returned.
    Returns:
      ButtonDefinition
    """
    return self.ui.commandDefinitions.addButtonDefinition(
      self.command_id,
      self.command_name,
      self.command_description,
      self.resource_dir)
0 Likes
Message 4 of 6

marshaltu
Autodesk
Autodesk

Hello,

 

Thank you for detailed information. I agree it should be separate issue which the menu didn't appear under sketch panel in my machine. Now I can reproduce your issue in my mac machine. I misunderstood "Flat Pattern" view. I will log a defect against the issue in our internal bug system.

 

Thanks,

Marshal



Marshal Tu
Fusion Developer
>
0 Likes
Message 5 of 6

Anonymous
Not applicable

Ya, I had to take a moment to understand my user's complaint about this myself 😉

0 Likes
Message 6 of 6

thomasa88
Advocate
Advocate

Was this ever resolved? I'm having a hard time finding the flat pattern menus in allToolbarTabs/allToolbarPanels.

0 Likes