spettitt Posted November 26, 2023 Share Posted November 26, 2023 (edited) Hello, I have a script for Panel Layouts in ConnectCAD that was working until Panel Layouts changed in Update 2. They've changed for the better for sure, but I need to figure out how to make my script work again. When a Panel Layout object was created prior to U2, it contained geometry and Panel Connector PIOs within the profile group. My script (snippet below) iterated through these Panel Connectors when given the handle to the panel layout object. We were using them unstyled at that point. Because of improvements with Update 2, they are now generally styled. So a panel layout object instance would use a named style 'Panel AVB101' that will contain geometry and a selection of Panel Connectors. So now, I need to access the contents of the referenced Style rather than the panel layout instance. I can return the name of the style easily using GetPluginStyle, but I'm not sure how to get the handle to it, or if a handle would even exist for a style. I just need to access the contents of the style such that I can iterate getfield over each Panel Connector in the Style (getfield itself validates that each object is a Panel Connector PIO) def preppanelconns(hpanellayout): styname = vs.GetPluginStyle(hpanellayout) vs.AlrtDialog(styname) hprofilegroup = vs.GetCustomObjectProfileGroup(hpanellayout) vs.ForEachObjectInList(getfield, 0, 1, vs.FInGroup(hprofilegroup)) Any ideas appreciated, please. Edited November 26, 2023 by spettitt Quote Link to comment
Pat Stanford Posted November 26, 2023 Share Posted November 26, 2023 GetPlugInStyleSymbol should get you a handle to the Symbol the defines the style. GetObject('Style Name') might work also. Quote Link to comment
spettitt Posted November 26, 2023 Author Share Posted November 26, 2023 Thank you Pat. That's got me quite a bit further. I couldn't work out why GetPlugInStyleSymbol needed two arguments but I've gotten the below working: def preppanelconns(hpanellayout): sty_name = vs.GetPluginStyle(hpanellayout) # gets the name of the panel style sty_hdl = vs.GetObject(sty_name) # Function GetObject returns a handle to a named object sty_sym_name = vs.GetPluginStyleSymbol(hpanellayout, sty_hdl) # gets the symbol from the panel style sty_sym_hdl = vs.GetObject(sty_name) # get handle of the used symbol # vs.AlrtDialog(f"style name is {sty_name}. getting the object handle of the panel style name is P{sty_hdl}. getting the symbol name for the panel style is {sty_name}. getting the handle of the panel symbol is {sty_sym_hdl}") # hprofilegroup = vs.GetCustomObjectProfileGroup(hpanellayout) - saved for later, may need again if panel is unstyled vs.ForEachObjectInList(getfield, 0, 2, vs.FInSymDef(sty_sym_hdl)) My next challenge is getting the panel layout symbol definition to refresh itself via the script to actually have some data to retrieve, but that's a tomorrow problem I think. At the moment, when I run the Create Panel View command and choose a Style to base my new Panel Layout on, the Panel-specific style in the Resource Manager is created along with the instance in the drawing, but I need to find the style in the RM, edit, enter the Device Name and 'Update from Schematic' for it to pull the data. I'll check in over at the ConnectCAD forum, I'm sure it can be done somehow. Quote Link to comment
Pat Stanford Posted November 26, 2023 Share Posted November 26, 2023 I don't know enough about the ConnectCAD objects to know, but my expectation with normal styles PIOs would be something like: Edit the Style ResetObject on the Style Symbol in the RM ResetObject for each object using that Style. GetPluginStyleSymbol needs two handles because the first is the handle to the styled object. The second is the returned handle to the Style Symbol. You shouldn't need both GetPluginStyleSymbol and GetObject. sty_hdl and sty_sym_hdl should both give you the same object. Glad I was of some help. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.