Anyone has any ideas why the following produces an empty dyn_string:
dyn_string shapes = getShapes(myModuleName(), myPanelName(), "shapeType", "PANEL_REF");
?
shapeType is a primitive shape attribute and if I do the following:
dyn_string shapes = getShapes(myModuleName(), myPanelName(), "", "");
I can see PANEL_REFs returned in the list, but is there a way to pick just those when "scanning" a panel?
Basically I'm trying to fetch the names of PANEL_REFs which are of a specific type, to read their $params.
getShapes() doesn't work with "shapeType" / "PANEL_REF"
- tpjctrl
- Posts:145
- Joined: Tue May 08, 2018 10:30 am
getShapes() doesn't work with "shapeType" / "PANEL_REF"
- dbindernagel
- Posts:161
- Joined: Mon Feb 23, 2015 1:34 pm
Re: getShapes() doesn't work with "shapeType" / "PANEL_REF"
I guess this is the case because a PANEL_REF is not a "real" shape but just the reference to a panel that contains shapes.
It would be really helpful to have a function that would return panel references.
What you can do is to get all shapes and then check for a dot "." in the name to distinguish between PANEL_REF and normal shapes (assuming you don't have a dot in your shape names).
It would be really helpful to have a function that would return panel references.
What you can do is to get all shapes and then check for a dot "." in the name to distinguish between PANEL_REF and normal shapes (assuming you don't have a dot in your shape names).
Code: Select all
dyn_string getPanelReferences()
{
dyn_string shapes, references;
shapes = getShapes(myModuleName(), myPanelName(), "");
for (int i = 1; i <= dynlen(shapes); i++)
{
// Check if shape is a reference (will have a dot in the name).
if (!shapes[i].contains("."))
continue;
shape reference = getShape(shapes[i].split(".")[0]);
// Optional: Check if PANEL_REF is desired type.
if (strpos(reference.panelFileName, "refname.xml") < 0)
continue;
if (!dynContains(references, reference.name))
dynAppend(references, reference.name);
}
return references;
}- tpjctrl
- Posts:145
- Joined: Tue May 08, 2018 10:30 am
Re: getShapes() doesn't work with "shapeType" / "PANEL_REF"
Indeed, if you look inside any XML panel file with a panel ref, you'll see that the panel refs have no shape type attribute.
Thanks for the code sample, I'll give it a go.
Thanks for the code sample, I'll give it a go.