Python Autodesk.Revit.DB.ElementId() Examples

The following are 3 code examples of Autodesk.Revit.DB.ElementId(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module Autodesk.Revit.DB , or try the search function .
Example #1
Source File: Parse.ErrorReport.py    From SpringNodes with MIT License 5 votes vote down vote up
def getElement(i):
	try: return doc.GetElement(ElementId(i)).ToDSType(1)
	except: return i 
Example #2
Source File: Parse.InterferenceCheck.py    From SpringNodes with MIT License 5 votes vote down vote up
def getElement(i):
	try: return doc.GetElement(ElementId(i)).ToDSType(1)
	except: return i 
Example #3
Source File: DirectShape.ByGeometry.py    From SpringNodes with MIT License 4 votes vote down vote up
def NewDS(s1, cat1, name1):
	temp_path = System.IO.Path.GetTempPath()
	sat_path = "%s%s.sat"% (temp_path, name1)
	try:
		if factor != 1:
			s1 = s1.Scale(factor)
		sat1 = Geometry.ExportToSAT(s1, sat_path)
		satId = doc.Import(sat1, satOpt, view1)
		el1 = doc.GetElement(satId)
		geom1 = el1.get_Geometry(opt1)
		enum = geom1.GetEnumerator()
		enum.MoveNext()
		geom2 = enum.Current.GetInstanceGeometry()
		enum2 = geom2.GetEnumerator()
		enum2.MoveNext()
		s1 = enum2.Current
		doc.Delete(satId)
		System.IO.File.Delete(sat_path)
		
		if cat1 is None or not RVT.DirectShape.IsValidCategoryId(cat1.Id, doc):
			cat1Id = RVT.ElementId(RVT.BuiltInCategory.OST_GenericModel)
		else:
			cat1Id = cat1.Id

		if name1 in dst_enum:
			old_type = dst_enum[name1]
			old_type.SetShape([s1])
			fec1 = RVT.FilteredElementCollector(doc).OfClass(RVT.DirectShape).WhereElementIsNotElementType()
			insts = [i for i in fec1 if i.GetTypeId().Equals(old_type.Id)]
			if insts:
				ds1 = insts[0]
			else:
				dsLib.AddDefinitionType(name1, old_type.Id)
				if isRvt2017:
					ds1 = RVT.DirectShape.CreateElementInstance(doc, old_type.Id, cat1Id, name1, tf1)
				else:
					ds1 = RVT.DirectShape.CreateElementInstance(doc, old_type.Id, cat1Id, name1, tf1, "Dynamo", "spring nodes")
				ds1.SetTypeId(old_type.Id)
		else:
			dsType1 = RVT.DirectShapeType.Create(doc, name1, cat1Id)
			dsType1.SetShape([s1])
			dsLib.AddDefinitionType(name1, dsType1.Id)
			dst_enum[name1] = dsType1
			if isRvt2017:
				ds1 = RVT.DirectShape.CreateElementInstance(doc, dsType1.Id, cat1Id, name1, tf1)
			else:
				ds1 = RVT.DirectShape.CreateElementInstance(doc, dsType1.Id, cat1Id, name1, tf1, "Dynamo", "spring nodes")
			ds1.SetTypeId(dsType1.Id)

		return ueWrapper.Invoke(None, (ds1, False) )
	except:
		return traceback.format_exc()