Hi,
A strange behavior when getting geometry for the second solid causing inaccuracy.
I am creating 2 sloped roofs and preparing references for placing flashing and gutter.
For the first roof it works correctly and generates correct lines with correct z values.
for the second roof, it reads the geometry as a non sloped solid. (see the blue lines below)
roofs.dyn (8.0 KB)
import clr
import math
#Import Revit Nodes
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.GeometryReferences)
# Import RevitAPI
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from clr import StrongBox
# Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import System
import RevitServices
doc = DocumentManager.Instance.CurrentDBDocument
#extract references
optA = Options()
optA.ComputeReferences = True
optB = Options()
optB.ComputeReferences = True
#The inputs to this node will be stored as a list in the IN variables.
level = UnwrapElement(IN[0])
type = UnwrapElement(IN[1])
slopeAngle = 15
curveNo = 2
x1 = 0
x2 = 4000
y1 = 0
y2 = 3000
ym = (y1+y2)/2
z = 0
linesA = []
linesB = []
roofA = []
roofB = []
rise = math.tan ( math.radians (slopeAngle))
#create lines for roof A
line = Line.ByStartPointEndPoint(Point.ByCoordinates(x1,y1,z), Point.ByCoordinates(x2,y1,z))
linesA.append(line)
line = Line.ByStartPointEndPoint(Point.ByCoordinates(x2,y1,z), Point.ByCoordinates(x2,ym,z))
linesA.append(line)
line = Line.ByStartPointEndPoint(Point.ByCoordinates(x2,ym,z), Point.ByCoordinates(x1,ym,z))
linesA.append(line)
line = Line.ByStartPointEndPoint(Point.ByCoordinates(x1,ym,z), Point.ByCoordinates(x1,y1,z))
linesA.append(line)
#create lines for roof B
line = Line.ByStartPointEndPoint(Point.ByCoordinates(x1,y2,z),Point.ByCoordinates(x2,y2,z))
linesB.append(line)
line = Line.ByStartPointEndPoint(Point.ByCoordinates(x2,y2,z),Point.ByCoordinates(x2,ym,z))
linesB.append(line)
line = Line.ByStartPointEndPoint(Point.ByCoordinates(x2,ym,z),Point.ByCoordinates(x1,ym,z))
linesB.append(line)
line = Line.ByStartPointEndPoint(Point.ByCoordinates(x1,ym,z),Point.ByCoordinates(x1,y2,z))
linesB.append(line)
TransactionManager.Instance.EnsureInTransaction(doc)
#create roof A
footprintA = CurveArray()
for line in linesA:
footprintA.Append(line.ToRevitType())
roofCurvesA = StrongBox[ModelCurveArray](ModelCurveArray() )
footprintRoofA = doc.Create.NewFootPrintRoof(footprintA, level, type, roofCurvesA)
roofA.append(footprintRoofA.ToDSType(False))
intA = roofCurvesA.Item[curveNo]
footprintRoofA.set_DefinesSlope( intA, True )
footprintRoofA.set_SlopeAngle( intA, -rise )
#create roof B
footprintB = CurveArray()
for line in linesB:
footprintB.Append(line.ToRevitType())
roofCurvesB = StrongBox[ModelCurveArray](ModelCurveArray() )
footprintRoofB = doc.Create.NewFootPrintRoof(footprintB, level, type, roofCurvesB)
roofB.append(footprintRoofB.ToDSType(False))
intB = roofCurvesB.Item[curveNo]
footprintRoofB.set_DefinesSlope( intB, True )
footprintRoofB.set_SlopeAngle( intB, -rise )
#Roof A
roofSolidA = UnwrapElement(roofA[0]).get_Geometry(optA)
#Roof B
roofSolidB = UnwrapElement(roofB[0]).get_Geometry(optB)
zvalA = []
zvalB = []
apexlist = []
bargelist = []
gutterlist = []
curveA = []
#Flasing Rood A
for i in roofSolidA:
edges = i.Edges
for c in edges:
curveA.append(c.AsCurve().ToProtoType())
if c.AsCurve().GetEndPoint(0).Z not in zvalA :
zvalA.append(c.AsCurve().GetEndPoint(0).Z)
zvalA.sort()
#reference for gutter roof A
for c in edges:
if (c.AsCurve().GetEndPoint(0).Z) == zvalA[0] and (c.AsCurve().GetEndPoint(1).Z) == zvalA[0] :
gutterlist.append(c.Reference)
#reference for apex roof A
for c in edges:
if (c.AsCurve().GetEndPoint(0).Z) == zvalA[3] and (c.AsCurve().GetEndPoint(1).Z) == zvalA[3] :
apexlist.append(c.Reference)
#reference barge roof A
for c in edges:
if ((c.AsCurve().GetEndPoint(0).Z) == zvalA[1] and (c.AsCurve().GetEndPoint(1).Z) == zvalA[3]) or ((c.AsCurve().GetEndPoint(0).Z) == zvalA[3] and (c.AsCurve().GetEndPoint(1).Z) == zvalA[1]) :
bargelist.append(c.Reference)
curveB = []
#Flasing Rood B
for i in roofSolidB:
edges = i.Edges
for c in edges:
curveB.append(c.AsCurve().ToProtoType())
if c.AsCurve().GetEndPoint(0).Z not in zvalB :
zvalB.append(c.AsCurve().GetEndPoint(0).Z)
zvalB.sort()
#reference for gutter roof B
for c in edges:
if (c.AsCurve().GetEndPoint(0).Z) == zvalB[0] and (c.AsCurve().GetEndPoint(1).Z) == zvalB[0] :
gutterlist.append(c.Reference)
#reference barge roof B
for c in edges:
if ((c.AsCurve().GetEndPoint(0).Z) == zvalB[0] and (c.AsCurve().GetEndPoint(1).Z) == zvalB[1]) or ((c.AsCurve().GetEndPoint(0).Z) == zvalB[1] and (c.AsCurve().GetEndPoint(1).Z) == zvalB[0]) :
bargelist.append(c.Reference)
TransactionManager.Instance.TransactionTaskDone()
OUT = roofA[0], roofB[0], apexlist, bargelist, gutterlist, curveA, curveB
please help me to find the error