Hello,
i have the topic allready solved in dynamo. and it runs amazing, BUT in Python i come to my limits:
- i can collect my items (also linked)
- i can get my values
- i can get locations
but
- i can`t create sphere
- i can`t intersect elements
- i can`t get the result
this my code so far
#🌈 links
linked_docs = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_RvtLinks).WhereElementIsNotElementType().ToElements()
lnkInstance = [i for i in linked_docs if i.Name.Contains("FM_AR")]
doclnk = lnkInstance[0].GetLinkDocument()
# 🛒 collect doors from linked file
doors = FilteredElementCollector(doclnk).OfCategory(BuiltInCategory.OST_Doors).WhereElementIsNotElementType().ToElements()
# 🔶 get Doornumbers
doorNumbers = [i.get_Parameter(BuiltInParameter.DOOR_NUMBER).AsString() for i in doors]
# ❓ Evaluate None Error
lis = []
for i in doorNumbers:
if i == None:
lis.append("---")
else:
lis.append(i)
# 1️⃣ Collector
collector = FilteredElementCollector(doc)\
.OfCategory(BuiltInCategory.OST_ElectricalFixtures)\
.WhereElementIsNotElementType()\
.ToElements()
# 🧲 holding magnets
magnets = [i for i in collector if doc.GetElement(i.GetTypeId()).Family.Name.Contains("Haltemagnet")]
# 1️⃣ origin of magnets
locationPoints = [i.Location.Point for i in magnets]
# 2️⃣ point at magnet
points = []
for i in locationPoints:
revit_xyz = XYZ(i.X,i.Y,i.Z)
revit_point = Point.Create(revit_xyz)
points.append(revit_point)
# 🔵 spheres for clash
spheres = []
for i in points:
radius = 1
dummy = GeometryCreationUtilities.CreateSphere(doc, i, radius, SolidOptions())
spheres.append(dummy)
print("\n{}".format(len(magnets)))
print("\n{}".format(doclnk))
print("\n{}".format(len(doors)))
i tried also with directShape, but there is no sphere at least i got no error
t = Transaction(doc,"Sphere")
t.Start()
spheres = []
for i in points:
radius = 1
geo = GeometryCreationUtilities.CreateSphere(doc, i, radius, SolidOptions())
# Create DirectShape element
geo = DirectShape.CreateElement(doc, ElementId.InvalidElementId)
geo.ApplicationId = "Dummy"
geo.ApplicationDataId = "ToClash"
geo.SetShape([geo])
spheres.append(geo)
t.Commit()