Renaming views after creation

Renaming views after creation

Anonymous
Not applicable
2,450 Views
3 Replies
Message 1 of 4

Renaming views after creation

Anonymous
Not applicable

Hi All,

 

I'm creating a routine that creates new plan views (structural plans) from the structural plans that are in my project, but these new structural plans will have a different view template.

 

The portion of the routine I made is as follows:

 

using (Transaction tx = new Transaction(doc, "View Creation"))
                {
                    tx.Start();

                    // Create new views with desired template applied
                    foreach (View v in plantas)
                    {
                        ElementId levelId = v.GenLevel.Id;
                        ViewPlan vista = ViewPlan.Create(doc, vft.Id, levelId);

                        vista.Name = vista.Name + " - Thick";
                        vista.Name.Replace("(1)", "");

                        // Apply the template
                        vista.ViewTemplateId = vTemplate.Id;
                    }                   

                    tx.Commit();
                }    

The problem is, that when I do this, Revit prompts a message telling that a unique name is needed, but in my code, after the view creation, I set a different name.

 

What am I missing here?

 

Thanks in advance!

Accepted solutions (1)
2,451 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Accepted solution

I found the solution to my problem. I had a repeated plan view that was making troubles.

 

My bad.

 

Cheers!

Message 3 of 4

jeremytammik
Autodesk
Autodesk

Dear Jorge,

 

Congratulations on solving your task.

 

Thank you for your update and letting us know.

 

Cheers,

 

Jeremy

 



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

0 Likes
Message 4 of 4

Anonymous
Not applicable
0 Likes