@Nick_Boyts, I haven’t gotten far enough to call gs1. I am trying to work through matching them I worked the code a little bit and I am testing against one filled region for clarity.
You can see here that I get all four lines of the filled region rectangle, and the GraphicStyle of each. Then the other out is gs2, the graphicStyle of the line I selected in the model. You can see that they match.
Code changes:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
region = UnwrapElement(IN[0])
geoOpt = app.Create.NewGeometryOptions()
gs1 = IN[1]
gs2 = IN[2]
TransactionManager.Instance.EnsureInTransaction(doc)
edgeArray = []
for r in region:
geoElem = r.get_Geometry(geoOpt)
enum1 = geoElem.GetEnumerator() ; enum1.MoveNext()
geo2 = enum1.Current
edgeArray.append(geo2.Edges)
lineStyles = []
for reg in edgeArray:
ls = []
lineStyles.append(ls)
for edge in reg:
ls.append(doc.GetElement(edge.GraphicsStyleId))
TransactionManager.Instance.TransactionTaskDone()
#Assign your outputs to the OUT variable
OUT = lineStyles, gs2
Image of what I see:
However, when I try to run the “if” against them in the following code, I get an empty list:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
region = UnwrapElement(IN[0])
geoOpt = app.Create.NewGeometryOptions()
gs1 = IN[1]
gs2 = IN[2]
TransactionManager.Instance.EnsureInTransaction(doc)
edgeArray = []
for r in region:
geoElem = r.get_Geometry(geoOpt)
enum1 = geoElem.GetEnumerator() ; enum1.MoveNext()
geo2 = enum1.Current
edgeArray.append(geo2.Edges)
lineStyles = []
for reg in edgeArray:
ls = []
lineStyles.append(ls)
for edge in reg:
if doc.GetElement(edge.GraphicsStyleId) == gs2:
ls.append(doc.GetElement(edge.GraphicsStyleId))
TransactionManager.Instance.TransactionTaskDone()
#Assign your outputs to the OUT variable
OUT = lineStyles, gs2
Here is what I get, an empty list.