- 20/01/2020 at 10:23 #20265
How to use the Python API to implement view manipulation functions that show global or focus on selected components?
The effect is equivalent to the first two items of the 3D world toolbar shown in the picture.020/01/2020 at 10:55 #20542
FillSelected and FillWorld can be accessed in python using netCommand which calls for a .NET action item by its name and executes it. I tested it on 4.2 and FillSelected seems to work but FillWorld doesn’t for some reason. But you can work around that using selection manager. Below you see python functions that should do the trick in 4.2:Python123456789101112#---def FillSelected():netcmd = app.findCommand('netCommand')netcmd.execute('FillSelected')#---def FillWorld():netcmd = app.findCommand('netCommand')sel = app.SelectionManager.getSelection(VC_SELECTION_COMPONENT)app.SelectionManager.setSelection(app.Components)netcmd.execute('FillSelected')app.SelectionManager.setSelection(sel)#---
-k022/01/2020 at 14:56 #20642
Thank you very much for solving my problem!
Regarding the function of “fillView”, I solved it by the following methods. 🙂Python123456789101112from vcScript import *app = getApplication()# focus on selected componentscmd = app.findCommand('netCommand')cmd.execute("FillSelected")# foucus on the whole layoutcmd2 = app.findCommand("fillView")cmd2.execute()app.render()022/01/2020 at 14:57 #20834
Oh, I didn’t know about fillView in python. Thanks for sharing it 🙂
You must be logged in to reply to this topic.