So I wrote a script that loops changes in parameters on sheets and title blocks and printing them. The problem is it prints without any errors and the parameters look fine. but the parameter graphics don’t get updated
see it used to work. but all of a sudden it stopped working.
here is the code( the major piece of it)
for BuildingNo,bldgDirection,Angle in zip(BuildingNoValue, DirectionValue, AngleValue):
TransactionManager.Instance.EnsureInTransaction(doc)
theSheet[0].SetParameterByName("BLDG. NO.", BuildingNo)
theSheet[0].SetParameterByName("UNIT ORIENTATION", bldgDirection)
elem = UnwrapElement(TitleBlock[0])
parameter = elem.LookupParameter("NR - ANGLE")
debuglist.append(parameter)
parameter.Set(Angle)
TransactionManager.Instance.TransactionTaskDone()
y = TitleBlock[0].GetParameterValueByName("NR - ANGLE")
debuglist.append(y)
PrintView(doc,theSheet,pRange, printerName, combined, filePath,printSetting)
OUT = debuglist
Think you’ll need to commit the transaction before you print. Swap the 3rd to last line with the second to last line and see if that works.
excuse me it was like that before. still no luck. i will update the script in question. thanks!
Can you post the full code including the print view definition? Need to see which api methods are in play, as my guess is a doc regenerate is needed but can’t know without the context.
HERE IS THE FULL CODE
import sys
import clr
import time
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
# Place your code below this line
# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
from Revit.Elements import*
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import System
#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN
sheets = IN[0]
pRange = System.Enum.Parse(Autodesk.Revit.DB.PrintRange, IN[1])
combined = IN[2]
printerName = IN[3]
printSetting = IN[4]
filePath = IN[5]
runIt = False
theSheet = IN[7]
parameterName = IN[8]
BuildingNoValue = IN[9]
AngleValue = IN[10]
DirectionValue = IN[11]
TitleBlock = IN[12]
titleparam = IN[13]
if isinstance(sheets, list):
viewSheets = []
for i in sheets:
viewSheets.append(UnwrapElement(i))
else:
viewSheets = UnwrapElement(sheets)
def PrintView(doc, sheet, pRange, printerName, combined, filePath, printSetting):
# create view set
#viewSet = ViewSet()
#viewSet.Insert(sheet)
# determine print range
printManager = doc.PrintManager
printManager.PrintRange = pRange
printManager.Apply()
# make new view set current
viewSheetSetting = printManager.ViewSheetSetting
#viewSheetSetting.CurrentViewSheetSet.Views = viewSet
# set printer
printManager.SelectNewPrintDriver("PDF Writer - bioPDF")
printManager.Apply()
# set combined and print to file
if printManager.IsVirtual:
printManager.CombinedFile = combined
printManager.Apply()
printManager.PrintToFile = True
printManager.Apply()
else:
printManager.CombinedFile = combined
printManager.Apply()
printManager.PrintToFile = False
printManager.Apply()
# set file path
#printManager.PrintToFileName = filePath
printManager.Apply()
# apply print setting
try:
printSetup = printManager.PrintSetup
printSetup.CurrentPrintSetting = printSetting
printManager.Apply()
except:
pass
# save settings and submit print
TransactionManager.Instance.EnsureInTransaction(doc)
viewSheetSetting.SaveAs("tempSetName")
printManager.Apply()
printManager.SubmitPrint()
viewSheetSetting.Delete()
TransactionManager.Instance.TransactionTaskDone()
return True
debuglist = []
for BuildingNo,bldgDirection,Angle in zip(BuildingNoValue, DirectionValue, AngleValue):
TransactionManager.Instance.EnsureInTransaction(doc)
theSheet.SetParameterByName("BLDG. NO.", str(BuildingNo))
theSheet.SetParameterByName("UNIT ORIENTATION", str(bldgDirection))
elem = UnwrapElement(TitleBlock)
parameter = elem.LookupParameter("NR - ANGLE")
debuglist.append(parameter)
parameter.Set(int(Angle))
y = TitleBlock.GetParameterValueByName("NR - ANGLE")
debuglist.append(y)
TransactionManager.Instance.TransactionTaskDone()
PrintView(doc,IN[7],pRange, printerName, combined, filePath,printSetting)
OUT = debuglist
Hello,
try to regenerate the current document with doc.Regenerate()
during the process
# some code
for BuildingNo,bldgDirection,Angle in zip(BuildingNoValue, DirectionValue, AngleValue):
TransactionManager.Instance.EnsureInTransaction(doc)
theSheet.SetParameterByName("BLDG. NO.", str(BuildingNo))
theSheet.SetParameterByName("UNIT ORIENTATION", str(bldgDirection))
elem = UnwrapElement(TitleBlock)
parameter = elem.LookupParameter("NR - ANGLE")
debuglist.append(parameter)
parameter.Set(int(Angle))
y = TitleBlock.GetParameterValueByName("NR - ANGLE")
debuglist.append(y)
TransactionManager.Instance.TransactionTaskDone()
doc.Regenerate() ## <- Add Here
PrintView(doc,IN[7],pRange, printerName, combined, filePath,printSetting)
# rest of code
2 Likes
it works for another file but not for a similar one with the same parameters
try to call the PrintView
function outside the loop at the end
# some code
TransactionManager.Instance.EnsureInTransaction(doc)
for BuildingNo,bldgDirection,Angle in zip(BuildingNoValue, DirectionValue, AngleValue):
theSheet.SetParameterByName("BLDG. NO.", str(BuildingNo))
theSheet.SetParameterByName("UNIT ORIENTATION", str(bldgDirection))
elem = UnwrapElement(TitleBlock)
parameter = elem.LookupParameter("NR - ANGLE")
debuglist.append(parameter)
parameter.Set(int(Angle))
y = TitleBlock.GetParameterValueByName("NR - ANGLE")
debuglist.append(y)
TransactionManager.Instance.TransactionTaskDone()
doc.Regenerate()
PrintView(doc,IN[7],pRange, printerName, combined, filePath,printSetting)
# rest of code
your code is difficult to understand:
- some input variables are unused
- content of input lists is unknown (empty list?)
- why you use a for loop to set parameters for one sheet?
- does your input titleblock correspond to the input theSheet?
the best is to share an example of file (if possible) too