Import Error:No module named Revitservices

Hello All,

I am going to make sheet creation dynamo script by using python script. I have make the python script for the same but one error massage is coming mentioned in below:

File “”, line 11, in
ImportError: No module named Revitservices.

I have attached the python script.

Please help me to resolved this error.

Thanks,

Hello
RevitServices instead of Revitservices. :wink:

oops! Thanks

@ranjit.chatterjee
copy paste all your Python code with </> tags, there are other small errors

#Make Sheets
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument
sheetnames = IN[0]
sheetnumber = IN[1]
titleblock = UnwrapElement(IN[2]) #unwrapped titleblock
sheetlist = list()

TransactionManager.Instance.EnsureInTransaction(doc) # you need an active transaction as you will create elements

for number in range(len(sheetnumber)):
    newsheet = Viewsheet.Create(doc,titleblock.Id)# create a new sheet where titleblock.Id is the id of the titleblock
    newsheet.Name = sheetnames[number]
    newsheet.SheetNumber = sheetnumber[number]
    sheetlist.append(newsheet.ToDSTtype(False))

TransactionManager.Instance.TransactionTaskDone()
Out = sheetlist

Some fixes and comments

Note titleblock must be an element Type
https://www.revitapidocs.com/2020/bc9e8be3-f3fd-97c2-2709-1d6eea3db775.htm

#Make Sheets
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument
sheetnames = IN[0]
sheetnumber = IN[1]
titleblock = UnwrapElement(IN[2]) #unwrapped titleblock need Type of titleblock
sheetlist = list()

TransactionManager.Instance.EnsureInTransaction(doc) # you need an active transaction as you will create elements

for name, number in zip(sheetnames, sheetnumber):  #sheetnames and sheetnumber are same length and same order
    newsheet = ViewSheet.Create(doc,titleblock.Id)# create a new sheet where titleblock.Id is the id of the titleblock
    newsheet.Name = str(number) #need to String
    newsheet.SheetNumber = name
    sheetlist.append(newsheet.ToDSType(False))

TransactionManager.Instance.TransactionTaskDone()
OUT = sheetlist
1 Like

Hi,

image

How to solve this above error.

You reference a variable that has not been defined before.
Check your code (same spelling, you had add one (s))

@ranjit.chatterjee your reply is deleted because same topic has been asked by you here

1 Like