Roof Gutter/Soffit by python script

thanks @lucamanzoni , you are right, I’ve deleted the row, now it gives another error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. 
Traceback (most recent call last):
  File "<string>", line 34, in <module>
AttributeError: 'List[object]' object has no attribute 'get_Geometry'

probably the Option syntax in Revit API 2016 is different

The python script that outputs the roof wouldn’t happen to return a list, would it?

Hi Teo,

I’m slightly confused, I included a working version your python above, RoofGutterIndex.dyn, but you aren’t using it?

Why not try the version I gave you?

My version has this code:

newGutter = doc.Create.NewGutter(type, ref)
gutter.append(newGutter.ToDSType(False))

I believe yours is partly failing because you are redefining gutter as not being a list, then you are trying to append as if it were still a list (someone will probably have a better explanation than me).

Hope that helps,

Mark

Dear @Mark.Ackerley , congrats with your forum celebration :slight_smile: !
Sorry, I am more confused as I just started using Dynamo and Python so I am messing everything :slight_smile: I need some time to get my head around the coding
to be honest I didn’t understand your nodes mostly because of this, please have a look at attached screenshot

Hi Teo, not sure about the slice of cake, it makes me hungry! :slight_smile:

Not that dyn, the other one…

RoofGutterIndex.dyn (7.0 KB)

That node is in Rhythm, but you could use Select Model Element, or any other method of getting the roof…

Hope that helps,

Mark

1 Like

I know it is confusing, the other graph looks complicated, but all it’s really doing is filtering down the edges to get the one you want…

I expect you need that control, but you could filter however you want…

What you will see is that I am sending the edges both as lines and references out of the first python…

The lines can be used to get properties such as being horizontal and at the top of the bottom edge… Then I apply that same filtering to the references, as only the references can be used to create the gutter.

Hope that helps,

Mark

1 Like

I used your Python code and still the same error comes:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. 
Traceback (most recent call last):
  File "<string>", line 34, in <module>
AttributeError: 'List[object]' object has no attribute 'get_Geometry'

Line Based Roof with slope and gutter 1.dyn (26.3 KB)

Hi Teo,

Try this, Line Based Roof with slope and gutter-MKA.dyn (26.8 KB)
the output from the roof was a list (containing a single item, but still a list), so it threw an exception, using a codeblock to call the first index of the list stops that…

Also, it didn’t like a number input… it was interpreting this as a number with a decimal, which it calls a float… you can’t use a float to call an index, because indexes are always whole numbers (integer)… So I changed that.

I had to use an Integer of 2, because, as described above, for whatever reason, 1 is not acceptable, perhaps it is a sloped edge…

Hope that helps,

Mark

2 Likes

@Mark.Ackerley You legend, it worked!!!
you are a real genius, thank you a lot

1 Like

Hi @MartinSpence, I’m trying to get your Python script work with a list of model lines instead of only one, but it’s not working . Do tou have any suggestion?

import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#Import ToDSType(bool) extensions method
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument

#Start scripting here:

gt = UnwrapElement(IN[0])

lines = UnwrapElement(IN[1])

ref = []

for i in range(len(lines)):
  ref.append(reference(lines[i])

TransactionManager.Instance.EnsureInTransaction(doc)

fascia = doc.Create.NewFascia(gt, ref).ToDSType(False)

TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable.
OUT = fascia

Hi @Cristiano,

Try this:

import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#Import ToDSType(bool) extensions method
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument

#Start scripting here:

gt = UnwrapElement(IN[0])

lines = UnwrapElement(IN[1])

ref = ReferenceArray()

for i in range(len(lines)):
	ref.Append(lines[i].GeometryCurve.Reference)

TransactionManager.Instance.EnsureInTransaction(doc)

fascia = []
for i in ref:
	fascia.append(doc.Create.NewFascia(gt, ref).ToDSType(False))

TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable.
OUT = fascia

Four Fascias made from Model Lines:

1 Like

Thank you Martin! It works great.
I just made a correction: there was a double iteration and it was creating duplicate fascias.


import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#Import ToDSType(bool) extensions method
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument

#Start scripting here:

gt = UnwrapElement(IN[0])

lines = UnwrapElement(IN[1])

ref = ReferenceArray()

for i in range(len(lines)):
	ref.Append(lines[i].GeometryCurve.Reference)

TransactionManager.Instance.EnsureInTransaction(doc)

fascia = [doc.Create.NewFascia(gt, ref).ToDSType(False)]

TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable.
OUT = [fascia,ref]

No probs!

And ah yes, I see now. Ofcause the method just need the CurveArray(). It doesn’t need to be iterated :-).

Cheers!