Filteredelement collector not working for structural walls

Hi ALL,
I am trying to collect walls from linked models in a particular view, for that i have created a solid in 3d view and trying to collect all walls clashing with that solid…Its working fine for architectural walls but not working for structural walls any idea?..


for line in lines:
	cl.Append(line.ToRevitType())



cslistcurveloop = List[CurveLoop]()
cslistcurveloop.Add(cl)


solid = GeometryCreationUtilities.CreateExtrusionGeometry(cslistcurveloop, XYZ.BasisZ, 5.0) 

solidfilter = ElementIntersectsSolidFilter(solid)

revitlinkinstances = FilteredElementCollector(doc).OfClass(RevitLinkInstance).ToElements()

revitlinkdocuments = []
for instance in revitlinkinstances:
	revitlinkdocuments.append(instance.GetLinkDocument())
clashingwalls = []	
widthvalue = []
allcolumns = []
for document in revitlinkdocuments:
	walls = FilteredElementCollector(document).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().WherePasses(solidfilter).ToElements()

Is the link transformed? If so then you need to transform your solid before creating your filter. Linked elements only appear in the origin-to-origin location in the Revit API context not where you see it in Revit.

1 Like

I am not aware about transform.Can you explain more?..how to do it?

  1. Get the total transform from the link instance.
  2. Invert it.
  3. Transform the solid (there are simple methods in the SolidUtils class to do this)
  4. Create the solid intersection filter.
  5. Pass it into the filtered element collector.

You’ll therefore need to move the above inside your for statement.

2 Likes

okay…Let me try

below is the code I wrote…can you help me to find where i am doing wrong regarding transform
for line in lines:
cl.Append(line.ToRevitType())

cslistcurveloop = ListCurveLoop
cslistcurveloop.Add(cl)

solid = GeometryCreationUtilities.CreateExtrusionGeometry(cslistcurveloop, XYZ.BasisZ, 5.0)

solidfilter = ElementIntersectsSolidFilter(solid)

revitlinkinstances = FilteredElementCollector(doc).OfClass(RevitLinkInstance).ToElements()

revitlinkdocuments =
for instance in revitlinkinstances:
transform = instance.GetTotalTransform()
revitlinkdocuments.append(instance.GetLinkDocument())
clashingwalls =
widthvalue =
allcolumns =
n = 0
for document in revitlinkdocuments:

instance = revitlinkinstances[n]
transform = instance.GetTotalTransform()


newsolid = CreateTransformed(solid,transform)

solidfilter = ElementIntersectsSolidFilter(newsolid)
walls = FilteredElementCollector(document).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().WherePasses(solidfilter).ToElements()
#columns = FilteredElementCollector(document).OfCategory(BuiltInCategory.OST_StructuralColumns).WhereElementIsNotElementType().WherePasses(solidfilter).ToElements()

clashingwalls.append(walls)
n = n + 1

TransactionManager.Instance.TransactionTaskDone()

You aren’t calling CreateTransformed correctly. How is the Python interpreter supposed to know which class CreateTransformed is from?

You also haven’t inverted the transform, which means the solid will be double the transform of the link instance, rather than relative to it.

The list of documents is superfluous which means so too is the extra for statement. Also the RevitLinkInstance stores the transform not the document and you need the transform since multiple instance of the same document can be linked into a Revit document all of which can have different transforms.

Naming conventions are poor :stuck_out_tongue_winking_eye:.

Your code needs to do this:

for line in lines:
	cl.Append(line.ToRevitType())

curveloopList = List[CurveLoop]()
curveloopList.Add(cl)

solid = GeometryCreationUtilities.CreateExtrusionGeometry(curveloopList, XYZ.BasisZ, 5.0)

revitLinkInstances = FilteredElementCollector(doc).OfClass(RevitLinkInstance).ToElements()

clashingWalls = []
widthValue = []
allColumns = []

for instance in revitLinkInstances:
	transform = instance.GetTotalTransform()

	transformedSolid = SolidUtils.CreateTransformed(solid, transform.Inverse)

	solidfilter = ElementIntersectsSolidFilter(transformedSolid)

	linkDocument = instance.GetLinkDocument()

	walls = FilteredElementCollector(linkDocument).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().WherePasses(solidfilter).ToElements()

	clashingWalls.append(walls)
2 Likes

perfect…It worked…Thanks a lot :smiley: :smiley:

1 Like