Community
PowerShape and PowerMill API Forum
Welcome to Autodesk’s PowerShape and PowerMill API Forums. Share your knowledge, ask questions, and explore popular API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

.ActiveModel returning more than expected.

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
nbaranowski
668 Views, 4 Replies

.ActiveModel returning more than expected.

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

Tags (2)
4 REPLIES 4
Message 2 of 5

 

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.


Luke Edwards
Consulting Services Manager
Message 3 of 5

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 

Message 4 of 5

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!)?


Luke Edwards
Consulting Services Manager
Message 5 of 5

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report