Import Error:No module named Revitservices again

Hi everyone,

I am following ArchSmarters python code to create Placeholder Sheets. I am getting the error as seen in the pic below.

I don’t think it’s the code. I think it has something to do with the RevitServices.dll file and/or its location. If I have made a mistake with the code, please direct me. I followed it from this video. https://www.youtube.com/watch?v=LPk0LMjsyy8

Where should the RevitServices.dll file be located? I am on a work computer and thought it may need to be in the “Users” folder but not sure.

I am in Revit 2023 with Dynamo V2.16.4

Below is my script.

# Load the Python Standard and DesignScript Libraries
import sys
import clr

clr.AddReference('ProtoGeometry')
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')

from RevitServices.Persistence import DocumentManager
from RevitServices.Transaction import TransactionManager
from Autodesk.Revit.DB import BuiltInCategory, FilteredElementCollector, ViewSheet, Transaction

# The inputs to this node will be stored as a list in the IN variables.
sheetNumbers = IN[0]
sheetNames = IN[1]

# Get the current Revit document
doc = DocumentManager.Instance.CurrentDBDocument

# Start a transaction
t = Transaction(doc, "Create Placeholder Sheets")
t.Start()

# Create the specified number of placeholder sheets
placeholderSheets = []

for i in range(len(sheetNumbers)):
    sheet = ViewSheet.CreatePlaceholder(doc)
    sheet.Name = sheetNames[i]
    sheet.SheetNumber = sheetNumbers[i]
    placeholderSheets.append(sheet)
    
 # Commit transaction
t.Commit()
 
# Assign your output to the OUT variable.
OUT = placeholderSheets

Cheers and thank you!

Try using import RevitServices after you add the reference.

1 Like

Is this where you would place it? I’m still getting the error.

Check my boilerplate here. I use this in most nodes.

Line 23-26 show how to set up revitservices.

1 Like

Hi,

add a “s” at RevitServices.Transactions

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
1 Like

Thank you for your reply Gavin and the boilerplate code! I’m going to stick it in my code to learn from it and mess around with it. I love your vids BTW.

1 Like

That was it! I was able to take out the “import RevitServices” line as per Nicks post. Thank you all for your help. I looked over the code so many times my eyes were blind to that one mistake. haha. Not even AI could pick up on the mistake.