Middlepoint element in view

Dear Specialists,

I would like to receive the middlepoint of a wall or other element (to tag).
When I search for the middle I receive the middlepoint of the whole element.
I would like to receive the middle of only the part that is visible.

Could anyone help me?
Thanks in advance! I am working with and in Python Dynamo.

Try intersecting the geometry with the surface of the view’s crop boundary pulled onto the view plane.

1 Like

try with this example,

Hi, how do you use standard nodes to obtain the geometry of each layer?
cordially
christian.stan

(didn’t realize this was a wall detail)
This should be a good outline:

  1. Get the wall’s geometry.
  2. Get the wall’s exterior face and convert to a surface. The element hosting utilities class has a method that helps here.
  3. Get the wall’s type.
  4. Get the layer thicknesses from the type.
  5. Do mass addition on the thicknesses to get total offset at each layer, dropping the last value.
  6. Offset the exterior surface by -1* the summed thicknesses.
  7. Split the geometry of the wall by the offset surfaces.
  8. Intersect the resulting solids with the view plane.
  9. Intersect the resulting surface with the view’s crop boundary as a solid or surface to get trimmed surfaces of each layer.
  10. Pull the perimeter curves and loft opposite edges to get an untrimmed surfaces.
  11. Get the point at parameter 0.5,0.5 - this is as accurate as I think you can readily get to the center of each wall part.
1 Like

Thank you, between 2 messages I searched a little in the API
I was thinking of working in a system coordinate linked to the exterior face and using a recurring function (not my strong point at all) to divide the solid with the Geometry.Split node


I will analyze your protocol
Sincerely
christian.stan

I might have missed making a polysurface from the offset surfaces, but the overall logic should be sound.

1 Like

Hi,
There is something that escapes me on your point 2

I use the HostObjectsUtils class to find reference of the exterior face

ref=HostObjectUtils.GetSideFaces(wall,ShellLayerType.Exterior)

but throws the element back at me I must be doing it wrong

OUT =ref[0].ElementReferenceType,sol1.ToProtoType(),ref[0].ElementId.IntegerValue

if I look at enumerator it’s 2 yet Heads, weird

Sincerely
christian.stan

The API call returns a list of References - GetSideFaces Method.

That means you need to add a step to get the geometry from the reference if you want to get to a surface - GetGeometryObjectFromReference Method

1 Like

I’m a loser, I already asked the question, sorry

thanks
cordially
christian.stan

Nah - you’re awesome.

It’s the complexity of the steps involved for something which ought to be simple that is a loser. Then again, without that complexity we wouldn’t be able to do a lot of what we take for granted.

1 Like

Hi, I followed your protocol at the beginning

I increased the cut faces if int and ext faces are not identical

I worked with recovery of geometry
if I tried it converted the solid into mesh not practical for the intersection of solid of the api

everything can be improved
thanks

Python Scripts

script 1

import sys
import clr

clr.AddReference("RevitAPI")
import Autodesk 
from Autodesk.Revit.DB import Wall,HostObjectUtils,ShellLayerType,UV

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

def accumu(lis):
    total = 0
    for x in lis:
        total += x
        yield total

wall=UnwrapElement(IN[0])
walltype=wall.WallType
cs=walltype.GetCompoundStructure()
ref=HostObjectUtils.GetSideFaces(wall,ShellLayerType.Exterior)
doc=wall.Document

faces=wall.GetGeometryObjectFromReference(ref[0])

ep=[0]
ep.extend(cs.GetWidth(i)*0.3048 for i in range(cs.LayerCount-1))

epc=list(accumu(ep))

OUT =faces.ToProtoType(),faces.ComputeNormal(UV()).Negate().ToVector(),epc

Script 2

import sys
import clr

clr.AddReference("RevitAPI")
import Autodesk 
from Autodesk.Revit.DB import Element,Solid,Options

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

VT=UnwrapElement(IN[0])
doc=VT[0].Document
sol = []
options = Options()
options.ComputeReferences = True

def solidrech(v):
    geoElement = v.get_Geometry(options)
    for obj in geoElement:
        return obj.GetInstanceGeometry()

OUT = [solidrech(v) for v in VT]

script 3

import sys
import clr

clr.AddReference("RevitAPI")
import Autodesk 
from Autodesk.Revit.DB import Solid,BooleanOperationsUtils,BooleanOperationsType

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

VT=UnwrapElement(IN[0])

OUT = [BooleanOperationsUtils.ExecuteBooleanOperation(VT[0],VT[i], BooleanOperationsType.Intersect).ToProtoType() for i in range(1,len(VT))]

Sincerely
christian.stan

1 Like