- #Revit sample project file 2018 how to
- #Revit sample project file 2018 code
- #Revit sample project file 2018 plus
Insert a shared parameter from the shared parameter file. ShowDialog() = DialogResult.OK)įoreach (string path in openFileDialog1.FileNames) OpenFileDialog1.InitialDirectory = folder here") OpenFileDialog openFileDialog1 = new OpenFileDialog() UIDocument uiDoc = this.ActiveUIDocument //dont need thisĭocument doc =
#Revit sample project file 2018 code
Note that this code is intended to be ran from within the family editor. Sometimes this is necessary for document level macros as opposed to application level macros. (Note the use of the “this” keyword in the following code which is used in macros to refer to the object that called the code. get_Parameter(BuiltInParameter.ELEM_PARTITION_PARAM). Parameter wsparam =e.get_Parameter(BuiltInParameter.ELEM_PARTITION_PARAM) Į. Using (Transaction tx = new Transaction(doc,"Change Workset"))
Uidoc.PromptForFamilyInstancePlacement(familySymbolToFind) If (familySymbol.Name = "receptacle" & = "duplex") Get a specific family name and type, and place it:įilteredElementCollector famil圜ollector = new FilteredElementCollector(doc) įamil圜ollector.OfClass(typeof(FamilySymbol)) įoreach (FamilySymbol familySymbol in famil圜ollector) Parameter myparam = e.LookupParameter("Comment") //lookup the value of the parameter named "Comment" Pickedtype = et.LookupParameter("Family Name") //get the name of the family typeĪ.Transaction t = new .Transaction(doc, "Change Parameter") Pickedtypeid = e.GetTypeId() //get the elements type (the id of the family the element belongs to)Įlement et = doc.GetElement(pickedtypeid) //get the family type from the type ID (similar to getting an element from if Comment is a integer parameter, mynumber should be declared as a integer Mynumber = e.LookupParameter("Note Number") //lookup the value of the parameter named "Note Number" if Comment is a text parameter, mycomment should be declared as a string Mycomment = e.LookupParameter("Comment") //lookup the value of the parameter named "Comment" Reference r = new Reference (element) //element to an element reference Here are some conversions:Įlement e = doc.GetElement(id) //element id to elementĮlement e = doc.GetElement(ref) //element reference to elementĮlementId id = ref.elementID //element reference to elementidĮlementId id = e.ID //element to an elementid Different commands need the element passed in different ways. The Revit API has 3 ways to work with elements, the element, the element id, or the element reference. Get an element from the element id or reference: TaskDialog.Show("Revit Keynote Editor", "Please only select receptacles.") If (e.Name.ToString() != "receptacle") //check each element to see if it is a receptacle Verify a selection is a certain family type:įoreach (ElementId id in selectedIds) //for each selected elementĮlement e = doc.GetElement(id) //get the element from the id
Get the element selection of current document.
#Revit sample project file 2018 plus
(You might have to expand one of the plus signs to see this line of code.) I'm not sure that is the proper place to put those variables, but it works.Īlso, it might be safer to declare them as private instead of public. That is right after the "endregion" line. You can pass variables and objects to functions through parameters, but sometimes it’s nice to have a variable that is available through-out your addin or macro.įor an addin, these can be defined right after the Iexternal command line:įor a macro, you can declare these right before your macro entry point.
#Revit sample project file 2018 how to
If you haven't heard of variable scope, you may be in for a tough time trying to figure out how to carry data from one part of you program to another.