Scripting: How to Open a PPG and Control Size and Location... and NOT be Modal

38 views
Skip to first unread message

Bradley Gabe

unread,
Oct 27, 2011, 4:44:37 PM10/27/11
to soft...@listproc.autodesk.com
One of the new scripting features added to SI was the ability to control PPG size upon opening using the SetViewSize() method.
Unfortunately, it only works when opening the PPG as a Modal window, which is useful for some, but not all tool sets developed using a native SI PPG interface.

In the event that it wasn't widely known, here's a technique you can use to open a PPG as a non-model view, yet have complete control over the size and location (sample code in Python):

#---8<-------------------------------------------------------------------------------
import win32com.client
#Get Pointer to your Custom Property (could be stored in Application.preferences)
oProp = Application.ActiveSceneRoot.AddProperty("MyCustomProperty", 0, "My Property")

#Get pointer to current Layout
oActiveLayout = Application.Desktop.ActiveLayout

#Create a new View and insert your custom property into it
oNewView = oActiveLayout.CreateView( "Property Panel", "My Custom Property" )

#Set Size and/or position of the view
oNewView.BeginEdit()
oNewView.Resize( 800, 680 )
oNewView.Move(10, 10)
oNewView.SetAttributeValue( "targetcontent", oProp.FullName )
oNewView.EndEdit()
#---8<-------------------------------------------------------------------------------

More information can be found in the SI docs under the View Object

If anyone knows any caveats about this technique offhand, please add it to the thread.

-Bradley

Matt Lind

unread,
Oct 27, 2011, 4:46:57 PM10/27/11
to soft...@listproc.autodesk.com

If you double click the blue titlebar to minimize the PPG, then double click to expand again, the contents will disappear.

 

 

Matt

Bradley Gabe

unread,
Oct 27, 2011, 4:52:42 PM10/27/11
to soft...@listproc.autodesk.com
It looks like the PPG runs its On_Init() function when you double-click to expand it.
This would probably reset the data for PPG's built on the fly, or living off nodes under the scene root.

However, I'm calling a Custom Property that is living in Application.preferences, so it does not lose its contents upon being re-expanded.

Matt Lind

unread,
Oct 27, 2011, 5:00:05 PM10/27/11
to soft...@listproc.autodesk.com

Another issue is the _OnClosed() PPGEvent does not get notifications when the user clicks the ‘x’ in the top right corner of the Property panel to close it.

Bradley Gabe

unread,
Oct 27, 2011, 5:05:38 PM10/27/11
to soft...@listproc.autodesk.com
Thanks!

So some pre-planning will need to happen for implementing a PPG this way.
  • Store Property in Application.presets first
  • Don't rely on OnInit or OnClosed PPGEvents
So far those limitations are reasonable for the freedom of sizing and moving a non-modal PPG. If I find more, I will add them to the thread.

Raffaele Fragapane

unread,
Oct 28, 2011, 12:36:55 AM10/28/11
to soft...@listproc.autodesk.com
If I had to guess what you were doing going by this thread and a previous one mentioning comboBox+text entries and captures, I would guess it's something that would enormously benefit from using Qt instead of the native model :)
Now that Steve and other have shared their efforts, it might actually cost you less time and blood than hammering nails with a screwdriver, which is what I think of working with PPGs to be like past a handful of sliders and a couple buttons.

Steven Caron

unread,
Oct 28, 2011, 1:31:52 AM10/28/11
to soft...@listproc.autodesk.com
I already tried to convert him but he had a good excuse, something
about and old dog and not being able to teach it something :P

*written with my thumbs

On Oct 27, 2011, at 9:36 PM, Raffaele Fragapane <raffsx...@googlemail.com

Reply all
Reply to author
Forward
0 new messages