Please Help! Python script error in a dynamo script

python

#1

Hey there,

I’m getting this error in the python code when I run this script. The input to it is "Family type (which is a titleblock family) - ElementID - IN(0)

I’m just not sure what the error messages means, as in what I need to do or input into it. Any guidance would be appreciated. If a copy of the script is also helpful happy to provide. This is the only error I’m getting.

Thanks


#2

Please post the entire python script using the Preformatted text option - the </> icon above the composition window.


#3
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

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

from System.Collections.Generic import *

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

titleBlockTypeId = IN[0] #Titleblock Family Type
sheetNumbers = IN[1] #Sheet Number [f]
sheetNames = IN[2] #Sheet Name [g]
onsheet = IN[3] #True/False ON SHEET Parameter [h]
param1 = IN[4]
WBSCODE = IN[5] #WBS CODE Parameter [i]
param2 = IN[6]
DISCIPLINE = IN[7] #AUR Discipline Parameter [j]
param3 = IN[8]
DOCTYPE = IN[9] #AUR DOC TYPE Parameter [k]
param4 = IN[10]
SheetStatus = IN[11] #Sheet Status Parameter [l]
param5 = IN[12]
SheetStatusNote = IN[13] #Sheet Status Note Parameter [m]
param6 = IN[14]
Title1 = IN[15] #TITLE 1 Parameter [n]
param7 = IN[16]
Title2 = IN[17] #TITLE 2 Parameter [o]
param8 = IN[18]
Title3 = IN[19] #TITLE 3 Parameter [p]
param9 = IN[20]
Title4 = IN[21] #TITLE 4 Parameter [q]
param10 = IN[22]
DwnBy = IN[23] #Drawn By Parameter [r]
param11 = IN[24]
DsgBy = IN[25] #Designed By Parameter [s]
param12 = IN[26]
ChkBy = IN[27] #Checked By Parameter [t]
param13 = IN[28]
AppBy = IN[29] #Approved By Parameter [u]
param14 = IN[30]
APPSgn = IN[31] #APP Signed Parameter [v]
param15 = IN[32]
APPDate = IN[33] #APP Date Parameter [w]
param16 = IN[34]
CERTName = IN[35] #CERT Name Parameter [x]
param17 = IN[36]
CERTNo = IN[37] #CERT No Parameter [y]
param18 = IN[38]
CERType = IN[39] #CERT TYPE Parameter [z]
param19 = IN[40]

# "Start" the transaction
TransactionManager.Instance.EnsureInTransaction(doc)

sheets = []
for f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z in zip(sheetNames, sheetNumbers, onsheet, WBSCODE, DISCIPLINE, DOCTYPE, SheetStatus, SheetStatusNote, Title1, Title2, Title3, Title4, DwnBy, DsgBy, ChkBy, AppBy, APPSgn, APPDate, CERTName, CERTNo, CERType):
    #create new sheet
    newSheet = ViewSheet.Create(doc, titleBlockTypeId[0])
    
    
        #set sheet name param
    bipName = BuiltInParameter.SHEET_NAME
    sheetNames = newSheet.get_Parameter(bipName)
    sheetNames.Set(f)   
    
    #set sheet number param
    bipNumber = BuiltInParameter.SHEET_NUMBER
    sheetNumbers = newSheet.get_Parameter(bipNumber)
    sheetNumbers.Set(g)   
    
 
        
    #set ON SHEET parameter
    onsheetParam = newSheet.get_Parameter(param1)
    onsheetParam.Set(h)   
    
    #set WBS CODE parameter
    WBSCODEParam = newSheet.get_Parameter(param2)
    WBSCODEParam.Set(i)      
    
    #set AUR DISCIPLINE parameter
    DISCIPLINEParam = newSheet.get_Parameter(param3)
    DISCIPLINEParam.Set(j)
    
    #set DOC TYPE parameter
    DOCTYPEParam = newSheet.get_Parameter(param4)
    DOCTYPEParam.Set(k)
    
    #set Sheet Status parameter
    SheetStatusParam = newSheet.get_Parameter(param5)
    SheetStatusParam.Set(l)
    
    #set Sheet Status Note parameter
    SheetStatusNoteParam = newSheet.get_Parameter(param6)
    SheetStatusNoteParam.Set(m)
    
    #set TITLE 1 parameter
    Title1Param = newSheet.get_Parameter(param7)
    Title1Param.Set(n)
    
    #set TITLE 2 parameter
    Title2Param = newSheet.get_Parameter(param8)
    Title2Param.Set(o)
    
    #set TITLE 3 parameter
    Title3Param = newSheet.get_Parameter(param9)
    Title3Param.Set(p)
    
    #set TITLE 4 parameter
    Title4Param = newSheet.get_Parameter(param10)
    Title4Param.Set(q)
    
    #set Drawn By Parameter parameter
    bipDwnBy = BuiltInParameter.SHEET_DRAWN_BY
    DwnBy = newSheet.get_Parameter(bipDwnBy)
    DwnBy.Set(r)
    
    #set Designed By Parameter parameter
    bipDsgBy = BuiltInParameter.SHEET_DESIGNED_BY
    DsgBy = newSheet.get_Parameter(bipDsgBy)
    DsgBy.Set(s)
    
    #set Checked By Parameter parameter
    bipChkBy = BuiltInParameter.SHEET_CHECKED_BY
    ChkBy = newSheet.get_Parameter(bipChkBy)
    ChkBy.Set(t)
    
    #set Approved By Parameter parameter
    bipAppBy = BuiltInParameter.SHEET_APPROVED_BY
    AppBy = newSheet.get_Parameter(bipAppBy)
    AppBy.Set(u)
    
    #set Approved Sign (APP Sign) parameter
    APPSgnParam = newSheet.get_Parameter(param15)
    APPSgnParam.Set(v)
   
    #set Approved Date (APP Date) parameter
    APPDateParam = newSheet.get_Parameter(param16)
    APPDateParam.Set(w)
    
    #set Cert Name (CERT Name) parameter
    CERTNameParam = newSheet.get_Parameter(param17)
    CERTNameParam.Set(x)
    
    #set Cert Number (CERT No) parameter
    CERTNoParam = newSheet.get_Parameter(param18)
    CERTNoParam.Set(y)
    
    #set Cert Type (CERT Type) parameter
    CERTypeParam = newSheet.get_Parameter(param19)
    CERTypeParam.Set(z)

#collect all newly created sheets
sheets.append(newSheet)	

# "End" the transaction
TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable
OUT = sheets

Let me know if you need anything else Thank you for responding!!


#5

newSheet = ViewSheet.Create(doc, titleBlockTypeId[0])

Can you try to remove [0] from titleBlockTypeId ?


#6

I just tried that, getting same error


#7

Sorry what’s this?


#8

Your TitleBlockFamily needs to use " UnwrapElement " method and get " Id " property from this.
Just see the example below.


#9

Where do I put that?

I put it in a python script just what you wrote between Familytypes and ElementID ran it had an error in python at the end still. Then got rid of that and just tried inserting that into that big python code at the end and I’m I’ve gotten this error on both occasions.

When I put that code into the end python though the warning about unsubscriptable is gone just replaced with this new one. S:


#10

if I take it straight from the python though and insert it into the python at the end this is the new error


#11

I also tried changing newSheet = to Sheet = but nothing same error in the python at the end @jean


#12

Crazy question here: why are you reinventing the wheel using python?

Creating sheets with a title block has been discussed many times now, and using one of those methods will likely save a lot of headaches. You can then use a variety of element.setparametermethods, including OOTB nodes.


#13

I found this old script that was created in 2015 in one of our archives and it is set up to use the exact type of excel sheet I want to use, with all the right parameter information and how we use titles on our title block so that it pre-fills all of the that upon insert - along with all the other blank sections. It has all the right input values and the script reflects that too. So instead of re-tailoring one to our standards from scratch again I just wanted to fix this one because then that would save me heaps of time is all. Seeing only one error came up and it was line 81 I thought perhaps fixing that would be simpler?
I’ve already got a script that creates sheets but doesn’t auto-fil all the parameters like this one is meant to.


#14

I’m a bit too inexperienced to be able to sort it out completely on my own so I thought I’d get some advice off the forum. If it’s going to be a bit of a nightmare and I am better off re-creating this and just inserting parameters in again and connecting the dots between the excel and the script again I’m willing to take the punch, Just let me know what your advice would be on it. Both responses show your knowledge and experience outweighs mine on this 100%!


#15

Reuse is a good reason, do you know who wrote the last one? If so they would be the ideal person to fix this.

I’m traveling back home from vacation today so I don’t have the capability to troubleshoot either very well.

By the looks of it, and as you sound like you’re more on the novice end of the user spectrum, utilizing the sheet creation nodes and then setting the parameter types might be easier to troubleshoot, as you’ll be able to test small groups and resolve individual issues at each node.


#16

Yeah I can’t find the person who created it I think they’re gone.

I really think being able to fix that python line would be ideal. I’m in no rush to solve this and happy to wait if that means you’d be able to help further?


#17

I’ll try and find the time between my work responsibilities (as with any other issue posted here), but I’m pretty booked up (going on vacation means more work at your return). I know most of the python super users tend to relax some on the weekends - one of them may pop by Monday.

What industry are you in? If I can fold this into work for a presentation I’m giving in a few weeks I may be able to expedite this.


#18

Engineering so getting this to run properly would be amazing. Generating hundreds of sheets all filled out for all MEP for example in one project would save heaps of time.
I’m just tweaking another script now that creates the views and applies a view template to them at the same time. Once I have that I can bring it into the script above I’m trying to get to work then it’ll generate views with correct VTs + Sheets w/ correct view assigned + entire title block filled out! Only leaving the modelling to be done. So much time saved.@JacobSmall


#19

@Jade

you know you can do this without Python?


#20

@Marcel_Rijsmus no I don’t know how to fix it without fixing this python line. Like I said it’s an old script, quite large I don’t know if it would take longer to deconstruct it then rejoin it to a node that = the same as the python script or whether just to fix the line. If you have any information that would make this task easier I am all ears!


#21

@Jade
something like this perhaps?