Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there.
I'm struggling with a lack of understanding about proxy.
The data is in this state and is attached.
I use the following code to select the profile. selectEntity is used to select the profile and then try to get the proxy, but I get an error with each one and cannot get it. (The same is true with SelectionCommandInput)
#Fusion360API Python script
import adsk.core, adsk.fusion, traceback
_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)
def run(context):
try:
global _app, _ui
_app = adsk.core.Application.get()
_ui = _app.userInterface
des :adsk.fusion.Design = _app.activeProduct
root :adsk.fusion.Component = des.rootComponent
msg :str = 'Select'
selFiltter :str = 'Profiles'
sel :adsk.core.Selection = selectEnt(msg ,selFiltter)
if not sel: return
prof :adsk.fusion.Profile = sel.entity
# test1
print('test1')
occ :adsk.fusion.Occurrence = prof.assemblyContext
try:
proxy = prof.createForAssemblyContext(occ)
print('{}:OK'.format(occ.name))
except:
print('{}:NG'.format(occ.name))
# test2
print('\ntest2')
for occ in root.allOccurrences:
try:
proxy = prof.createForAssemblyContext(occ)
print('{}:OK'.format(occ.name))
except:
print('{}:NG'.format(occ.name))
a=1
except:
if _ui:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def selectEnt(
msg :str,
filtterStr :str) -> adsk.core.Selection :
try:
sel = _ui.selectEntity(msg, filtterStr)
return sel
except:
return None
The result looks like this.
test1
Occurrence1:2:NG
test2
Occurrence1:1:NG
Occurrence1:2:NG
Does anyone know how to get the proxy from the user's selected profile?
Best regards.
Solved! Go to Solution.