Announcement

Collapse
No announcement yet.

Reading Painted materials from walls?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Reading Painted materials from walls?

    I've just been down a rabbit hole trying to find an answer to this but a pretty straightforward question - is there a way with Dynamo to read the material that is painted onto a wall surface?

    We are ideally trying to extract the material marks for the painted walls in our model. So far I have only been able to find online resources for actually painting surfaces, not for reading existing paint. Coding knowledge is very low so would need help on that front if it is required.
    Architectural BIM Specialist @ The Beck Group

    #2
    I believe it can. We looked in to it not too long ago to help an Interiors Group set up Finish Plans and "tags," but I could be misremembering how we did it, too. Pretty sure it works, though.

    Sent from my Pixel 3 XL using Tapatalk
    Aaron "selfish AND petulant" Maller |P A R A L L A X T E A M | Practice Technology Implementation
    @Web | @Twitter | @LinkedIn | @Email

    Comment


      #3
      Yes. You can. If I remember tomorrow I’ll find the code and post it here.

      Code:
      import clr
      
      clr.AddReference("RevitAPI")
      import Autodesk
      from Autodesk.Revit.DB import *
      
      clr.AddReference("RevitServices")
      import RevitServices
      from RevitServices.Persistence import DocumentManager
      
      from itertools import compress
      
      doc = DocumentManager.Instance.CurrentDBDocument
      
      rooms = UnwrapElement(IN[0])
      scale = IN[1]
      
      calculator = SpatialElementGeometryCalculator(doc)
      
      elementMaterial = list()
      elementMaterialID = list()
      elementEdgeS = list()
      elementEdgeE = list()
      elementRoom = list()
      elementFloor = list()
      elementCeiling= list()
      elementLoops= list()
      rSolid = list()
      normalList = list()
      for room in rooms:
      	results = calculator.CalculateSpatialElementGeometry(room)
      	roomSolid = results.GetGeometry()
      	rSolid.append(roomSolid)
      	roomMaterial = list()
      	roomMaterialID = list()
      	ceilingMaterialID = list()
      	floorMaterialID = list()
      	roofMaterialID = list()
      	roomEdgeS = list()
      	roomEdgeE = list()
      	roomLoops = list()
      	normals = list()
      	faceEdge = list()
      	floorFace = list()
      	normalZs = list()
      	
      	for face in roomSolid.Faces:
      		for subface in results.GetBoundaryFaceInfo(face):
      			boundingElement = subface.GetBoundingElementFace()
      			bBox = boundingElement.GetBoundingBox()
      			p=bBox.Min
      			q=bBox.Max
      			mid = p+.5*(q - p)
      			normalFace=boundingElement.ComputeNormal(mid)
      			normalZ = normalFace.Z
      			normalZs.append(normalZ)
      			if 0 < normalZ <= 1:
      				try:
      					fmaterialID = boundingElement.MaterialElementId
      					floorMaterialID.append(fmaterialID)
      					rmaterialID = boundingElement.MaterialElementId
      					roofMaterialID.append(fmaterialID)
      				except:
      					x=0
      			if 0 > normalZ >= -1:
      				try:
      					cmaterialID = boundingElement.MaterialElementId
      					ceilingMaterialID.append(cmaterialID)
      				except:
      					x=0
      			if normalZ == 0:
      				try:
      					materialID = boundingElement.MaterialElementId
      					materialName = doc.GetElement(materialID).Name
      					roomMaterialID.append(materialID)
      					faceEdge=face.EdgeLoops
      					loops=0
      					for loop in faceEdge:
      						
      						for fE in loop:
      							loops=loops+1
      							curve = fE.AsCurve()
      							p = curve.GetEndPoint(0)
      							q = curve.GetEndPoint(1)
      							roomLoops.append(loops)
      							roomEdgeS.append(p*scale)
      							roomEdgeE.append(q*scale)
      				except:
      					x=0
      	elementRoom.append(rSolid)
      	elementEdgeS.append(roomEdgeS)
      	elementEdgeE.append(roomEdgeE)	
      	elementMaterialID.append(roomMaterialID)
      	elementFloor.append(roofMaterialID)
      	elementCeiling.append(ceilingMaterialID)
      	normalList.append(normalZs)
      	elementLoops.append(roomLoops)
      	
      OUT = elementEdgeS,elementEdgeE,elementFloor,elementCeiling,elementMaterialID,elementLoops
      GMcDowellJr
      Forum Addict
      Last edited by GMcDowellJr; August 20, 2020, 05:02 PM.
      Greg McDowell Jr
      about.me/GMcDowellJr

      Comment


        #4
        https://revitforum.org/showthread.ph...-Problem/page3

        Comment


          #5
          Extremely helpful and would have never found that through search. I was able to adapt the script shown there for our own purposes (see image below). One major modification I made was to account for walls that are painted on both sides and assign those paints to different parameters. Our paint wall tag could thus have two types in case it was needed.

          Painted Material to Parameter_2020-08-20_12-37-32.pngPainted Material to Parameter_2020-08-20_12-37-32.png
          studiosally
          Junior Member
          Last edited by studiosally; August 20, 2020, 05:42 PM.
          Architectural BIM Specialist @ The Beck Group

          Comment


            #6
            One more minor change that is still great to have - I made the script also save a selection of all painted walls in the model. I used the Python code from this link:
            https://forum.dynamobim.com/t/save-selection-set-by-element/7481/2

            Final Dynamo script below.

            Painted Material to Parameter_2020-08-20_12-55-44.png
            Architectural BIM Specialist @ The Beck Group

            Comment

            Related Topics

            Collapse

            Working...
            X