I am using the API to take a set of screen captures for overlay purposes and build html templates. The first step is to ensure my user has only 3 levels on including creation. The problem i am having is that even though i visibly see 3 levels turned on, when i request a List of ActiveModels, i get a whole bunch of blank values returned as well as the 3 named levels i see. Where are these extra unnamed levels coming from?
//make sure only 3 levels are 'active' if (levels.Count == 3) { //Dim the level names oldData = levels[1].Name; newData = levels[2].Name; } else { MessageBox.Show("There are " + levels.Count().ToString() + "levels currently on, please Make sure only 3 levels are turned on, including level 0 (Creation)."); resetGUI(); return; }
In the above example, depending on the model i get my message saying there are 6 to 944 levels currently on even though there are only 3.
Is there a different method i can run to get what i need? I am assuming "active" doesn't mean what i think it does, but there is no "on/off" method.
Thank you!
-Nick
Solved! Go to Solution.
Solved by luke.edwards.autodesk. Go to Solution.
I assume you are referring to ActiveLevels rather than ActiveModel?
You should be able to do:
var levels = powerShape.ActiveModel.ActiveLevels;
If this isn't giving you what you expect then please can you provide some test data? My in built tests show this working as expected.
Yes ActiveLevels is what i am referring to sorry for the confusion. I figured out that i only experience the issue on models that were originally created in 2016. Can't figure out why though. i have to run this code in the beginning of my script to work around this.
//make sure blank levels are removed from the list foreach (PSLevel lvl in levels) { if (lvl.Name == "") lvl.IsActive = false; }
Otherwise even though i can see that there are 3 levels on in the model, i get a random amount of extras in levels.Count()
I have created a dropbox link to one of the models that i am experiencing this with. 2 levels are on and if you request psModel.ActiveLevels.Count() it returns 7.
https://www.dropbox.com/sh/bx63fc1vu5u37z4/AADaD0SE-1bnIs4lQ9nFwz6Na?dl=0
Looking at the model, you do have 7 active levels. However because they aren't named, they don't appear in the toolbar at bottom of PowerShape.
If you open the levels dialog and Filter to show Active levels then you will see 7 levels. I assume that at some point you have had these levels active and removed the name from them, hence they have dropped off the toolbar view at the bottom?
As far as I can see, it is all working as expected (albeit not quite as you expected!)?
You are 100% correct, i did not realize that after removing a level's name and deleting it's contents it is still active. That seems counter intuitive to me. Thank you for the clarification though, i will continue to run the check to turn off any levels without a name.