Results 1 to 4 of 4

Thread: Can you access the mark value from the Revit API?

  1. #1
    Member
    Join Date
    2015-09
    Posts
    8
    Login to Give a bone
    0

    Exclamation Can you access the mark value from the Revit API?

    Code:
    I am trying to write a macro for combining of 2 parameters into the mark parameter. I keep getting errors regarding mark not being found. Is the API able to push information into the mark parameter? Below is my code
    
    
                   		public void Mech_Equip()
    			{
    				Document doc = this.Document;
    				
    				string newMechID = "";
    				
    				using(Transaction trans = new Transaction(doc, "Rename Equipment"))
    				{
    					trans.Start();
    					
    					foreach (Element e in new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_MechanicalEquipment))
    					
    						OST_MechanicalEquipment Mech = e as OST_MechanicalEquipment;
    			
    						Parameter paramType = Mech.get_Parameter("TAG_MECH");
    						string MechType = paramType.AsString();
    						
    						Parameter paramInstance = Mech.get_Parameter("EQUIP_IDEN");
    						string MechInstance= paramInstance.AsString();
    					
    						string combinedName = MechType + "-" + MechInstance;
    					
    					
    						// This will assign the new name to the equipment
    						BuiltInParameter.ALL_MODEL_MARK = combinedName;
    			
    						newMechID += combinedName + "\n";
    					}
    			
    					trans.Commit();
    							
    					{
    						TaskDialog.Show ("Mechanical","List has been Updated");
    				}
    			}
    				;
    Last edited by willw663499; 2014-11-11 at 08:42 PM.

  2. #2
    Member
    Join Date
    2012-09
    Posts
    34
    Login to Give a bone
    0

    Default Re: Can you access the mark value from the Revit API?

    You've almost got it, but you're accessing the parameter incorrectly.

    Replace
    Code:
    BuiltInParameter.ALL_MODEL_MARK = combinedName;
    with:

    Code:
    Parameter markParam = Mech.get_Parameter(BuiltInParameter.ALL_MODEL_MARK);
    markParam.Set(combinedName);
    You could combine that into one line if you really wanted, but I think it's more clear split into 2.
    This also gives you the ability to verify that the parameter is of the correct type (string) if you weren't sure which type of parameter the mark parameter was.

  3. #3
    Member
    Join Date
    2015-09
    Posts
    8
    Login to Give a bone
    0

    Default Re: Can you access the mark value from the Revit API?

    That makes sense. Now it is telling me that "OST_MechanicalEquipment Mech = e as OST_MechanicalEquipment;" can not be a declaration. Does this mean i filtered it incorrectly?

  4. #4
    Member
    Join Date
    2010-05
    Location
    France
    Posts
    16
    Login to Give a bone
    0

    Default Re: Can you access the mark value from the Revit API?

    Hi, you have many errors in your code,
    Document doc = this.ActiveUIDocument.Document; For make change in your active document
    OST_MechanicalEquipment is not a type but a category name. Use this category in a FilterElementCollector for create a list of MechanicalEquipment
    You dont need to use newMechID

    Code:
    		public void Mech_Equip()
    		{
    			
    			Document doc = this.ActiveUIDocument.Document;
    			
    			FilteredElementCollector collector = new FilteredElementCollector(doc);
    			collector.OfCategory(BuiltInCategory.OST_MechanicalEquipment).WhereElementIsNotElementType().ToElements();
    			
    			using(Transaction trans = new Transaction(doc, "Rename Equipment"))
    			{
    				trans.Start();
    				
    				foreach (Element Mech in collector){
    					
    					Parameter paramType = Mech.get_Parameter("TAG_MECH");
    					string MechType = paramType.AsString();
    					
    					Parameter paramInstance = Mech.get_Parameter("EQUIP_IDEN");
    					string MechInstance= paramInstance.AsString();
    					
    					string combinedName = MechType + "-" + MechInstance;
    										
    					Parameter markParam = Mech.get_Parameter(BuiltInParameter.ALL_MODEL_MARK);
    					
    					markParam.Set(combinedName);
    				
    				}
    				
    				trans.Commit();
    			}
    		}
    HFloris

Similar Threads

  1. Shared Parameters for Elevation Mark, Section Mark, Callout Head & View Reference Families.
    By Wish List System in forum Revit Architecture - Wish List
    Replies: 2
    Last Post: 2021-04-21, 08:30 PM
  2. 2014: Elevation Mark vs Section Mark
    By Chris.Partin in forum Revit Structure - General
    Replies: 1
    Last Post: 2015-04-24, 03:56 PM
  3. 2013: Revit Mark
    By Ali1990 in forum Revit MEP - General
    Replies: 1
    Last Post: 2014-03-27, 08:47 PM
  4. How to find the next unused Type Mark or Mark?
    By Duncan Lithgow in forum Revit Architecture - General
    Replies: 5
    Last Post: 2012-07-31, 08:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •