Project Parameters - Delete All

Project Parameters - Delete All

barr.jarryd
Advocate Advocate
1,273 Views
6 Replies
Message 1 of 7

Project Parameters - Delete All

barr.jarryd
Advocate
Advocate

Hey folks,

 

I'm trying to build a macro that will completely wipe the project parameters(user defined settings), and I cannot seem to get a list or foreach loop to detect the parameters.

 

This is what I have so far but I keep getting an error that it cannot be evaluated.

 

FOREACH par IN FOLDER($Project._keys) {

        EDIT USERPAR project SELECT $par

        DELETE USERPAR project SELECTED

}

 

Many thanks for anyone that may have some insight into this matter.

0 Likes
Accepted solutions (1)
1,274 Views
6 Replies
Replies (6)
Message 2 of 7

Sean571
Advocate
Advocate

You need to remove the folder() and then also put the command in a DOCOMMAND. It's annoying but it's the only way to get variables to work in this case

FOREACH par IN $project._keys { 
    string $cmd = "EDIT USERPAR project SELECT '" + $par + "'"
    DOCOMMAND $cmd     
    DELETE USERPAR project SELECTED 
}
Sean Wroblewski
Applications Engineer

0 Likes
Message 3 of 7

Sean571
Advocate
Advocate

Shoot. This worked except it tries to delete more than what we want. Give me a sec and I'll come up with a solution

Sean571_0-1667600129475.png

 

Sean Wroblewski
Applications Engineer

0 Likes
Message 4 of 7

barr.jarryd
Advocate
Advocate

I got as far as doing this,

 

But $parameterName keeps giving me an error

FUNCTION Main() {

    INT parameterCount = 0 

    STRING parameterName = ""

    bool check = 1

    DIALOGS ERROR OFF

    WHILE $check == 1 {

        $parameterName = $project._keys[$parameterCount]

        EDIT USERPAR project SELECT $parameterName

        DELETE USERPAR project SELECTED

        $parameterCount = $parameterCount + 1

        $check = entity_exists($project._keys[$parameterCount])

    }

        MESSAGE INFO "All parameters deleted"

        DIALOGS ERROR ON

        MACRO ABORT ALL


}
0 Likes
Message 5 of 7

Sean571
Advocate
Advocate
Accepted solution

So there is actually a form that can lists all the project variables, and there are a few that we never want to delete. If you type in FORM PROJECTVARS in the command window you will see this dialog:

Sean571_0-1667600485760.png


So it's not pretty but this works:

string list defaultProjectVars = {"A360", "Customer", "FusionProductionJob", "HoleTagCatalog", "Notes", "OrderNumber", "PartName", "Programmer", "ProjectHistory", "TextBlocks", "ThicknessSets", "Tolerances"}

FOREACH par IN $project._keys { 
   If NOT member(defaultProjectVars, par) {
      string $cmd = "EDIT USERPAR project SELECT '" + $par + "'"
      DOCOMMAND $cmd     
      DELETE USERPAR project SELECTED 
   }      
}
Sean Wroblewski
Applications Engineer

Message 6 of 7

barr.jarryd
Advocate
Advocate

That worked awesome thank you!

 

I ended up with this by the end but yours is much better.

 

RESET LOCALVARS

    INT parameterCount = 0 

    STRING parameterName = ""

    STRING parameterCheck = ""

    STRING cmd = ""

    bool check = 0

    DIALOGS ERROR OFF

    WHILE $check == 0 {

        $parameterName = $project._keys[$parameterCount]

        $cmd = "EDIT USERPAR project SELECT " + "'" + $parameterName + "'"

        DOCOMMAND $cmd

        DELETE USERPAR project   SELECTED

        $parameterCount = $parameterCount + 1

        $parameterCheck = "$" + "project." + $parameterName

        $check = ERROR $parameterCheck

    }

        MESSAGE INFO "All parameters deleted"

        DIALOGS ERROR ON

        MACRO ABORT ALL
Message 7 of 7

danmic7JH66
Advocate
Advocate

I've been looking for a solution myself to this exact problem. Thanks for sharing.

 

0 Likes