I keep running into an error with this script and i can’t find the problem.
-some background
I’m working on a parking, where all floor are heavily edited with extra points
I created some Electrical Fixtures (2200) from a DWG file and placed them on the Levels (6)
Now i want to give them an offset to raise them so they touch the above concrete floor
I calculated the height they must be raised (in Z-Axis) by Raybounce
Some of my elements won’t respond, and i can’t find the problem.
I noticed that for whatever reason the raybouncing is hitting the same element you shoot the ray from and that’s why you only have one point there - they are coincident.
If you hide the electric fixtures in the view where you do the raybouncing everything works fine:
I also noticed that the ones that are already in place jump to the top face of the floor, since that’s where the ray bounces from. You will need to implement some sort of a check for those
Thnx @viktor_kuzev
I tried, no luck.
My Rays don’t hit anything in most cases.
In my main model(115 Mb) that i can’t upload here, it goes astray.
Would you use the same method? Or have other ideas how to get a step further?
Note.
Can’t use face based families here, afterwards i will split the model into Electrical model/Arch model.
Also Element.Faces or Element.Geometry will run forever on those floors
Thank you @jacob.small
Is there another way i can have Element.Geometry for these floors?
Did i see something like converting into Topology in the past?
Can you post a simplified RVT with just one of the failing floors? May require using the APIs (Dynamo and Revit) to construct the shape directly, but without seeing what the fail point is it’s impossible to know for sure.
Does ‘select face’ work perchance? Not that I would recommend ‘select the faces you want to project to manually’, but when in a crunch…
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
#Import ToDSType(bool) extensions method
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument
#---###Start scripting here:###---#
pts = IN[0]
rvtPts = [i.ToXyz() for i in pts]
ray = XYZ(0,0,1)
filter = ElementCategoryFilter(BuiltInCategory.OST_Floors)
distmidPt = []
midptNulls = []
for i, j in enumerate(rvtPts):
refI = ReferenceIntersector(filter, FindReferenceTarget.Face, doc.ActiveView)
#Make sure elements from links are included
refI.FindReferencesInRevitLinks = True
#Find nearest point that "hits"
refCmidPt = refI.FindNearest(j, ray)
#Get references from both points
if refCmidPt != None:
referencemidPT = refCmidPt.GetReference()
#Translate to global points
intersectmidPt = referencemidPT.GlobalPoint
#geommidPT.append(intersectmidPt)
#Get distance from startpoint to referece startpoint
distmidPt.append(UnitUtils.ConvertFromInternalUnits(j.DistanceTo(intersectmidPt), DisplayUnitType.DUT_MILLIMETERS))
else:
midptNulls.append(i)
OUT = distmidPt, midptNulls
I can see in the Dynamo view, all calculations worked.
In my test file it worked beautiful
Not on the main model though
You see why i think i have overlooked something
Maybe i should do a test, make a copy of the model, delete all the Elements except floors and Elec. Fixt. piece by piece .and run it, if it works i’ll bring back what i need, piece by piece (undo). If i choose the order in which i delete i can end up with the model i need anyway. I want to split by discipline .