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

Is it possible to change the walltype name through API

3 REPLIES 3
Reply
Message 1 of 4
jeffreybo.liu
336 Views, 3 Replies

Is it possible to change the walltype name through API

 I would like to change the walltype name of a wall through API, but it seems it does not work right. It seems the members in WallType cannot be modified, even public ones.

 

foreach (Element collectedElem in collection) {
                   
                    if (collectedElem.GetType().Name == "Wall") {
                        Wall wall = (Wall)collectedElem;
                                             
                    string wallValue=collectedElem.Level.Name+";"+collectedElem.Name;
                        
                    TaskDialog.Show("Wallvalue", wallValue);
    
                    if (walltype.Contains(wallValue) == false)
                    {
                  
                        walltype.Add(wallValue);                      
                    }
                    else {
                       
                        wall.WallType.Name="NewName";

                        TaskDialog.Show("change value", wall.WallType.Name  );
                    }
                    }
           
                }
                
                TaskDialog.Show("Test", "End of searching document!");
            }

3 REPLIES 3
Message 2 of 4

Dear jeffreybo.liu,

 

There is no reason why you cannot programmatically modify the name of a wall type.

 

However, your code below mixes together a number of different steps in one place.

 

I would suggest that you do one thing at a time, e.g. 

 

  • Iterate over the collector and store the desired wall element.
  • Close the iteration.
  • Extract the wall type from the selected wall. 
  • Open a transaction.
  • Change the wall type name.
  • Commit the transaction.

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 4

Thank you very much!:-)

 

I did not open a transaction before I made the change on the revit document. Revit threw it into an exception. I was too noooobie... Working harder~~

 

 

Message 4 of 4

I am glad it helped.

 

Please look at the getting started material before doing anything else:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#2

 

Especially, work through the My first plugin and DevTV tutorials.

 

That will give you the hang of things.

 

Cheers, 

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community