Message 1 of 6
Interior elevation rename
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am working on a routine to rename my interior elevations that is based on room information. Right now it is supposed to update all elevations but it does not appear to do anything. I eventually would like to make this routine only update selected elevation(s).
public void renameelevation()
{
Document doc = this.Document;
string newvname="";
using(Transaction tr = new Transaction(doc, "Rename Elevations"))
{
FilteredElementCollector collector= new FilteredElementCollector( doc ).OfClass( typeof(ViewSection ) );
tr.Start();
{
foreach(Element E in collector )
{
try
{
ViewSection current= E as ViewSection;
{
int value=0;
value++;
// Construct a point at the midpoint of the
// front bottom edge of the elev view cropbox
double xmax = current.CropBox.Max.X;
double xmin = current.CropBox.Min.X;
double zmax = current.CropBox.Max.Z;
XYZ pt = new XYZ(
xmax - 0.5 * ( xmax - xmin ),
1.0,
zmax);
// Get pt's translation to
// project coordinate system
pt = current.CropBox.Transform.OfPoint( pt );
Autodesk.Revit.DB.Architecture.Room rm
= doc.GetRoomAtPoint( pt );
if (null != rm)
{
string x = value.ToString();
string combinedName= "EI-"+rm.Number+x;
current.Name = combinedName;
newvname += combinedName + "\n";
}
}
}
catch(Exception)
{
}
}
}
tr.Commit();
}
}Thanks