I’m working on a project which is to have a dynamo which is able to convert all my desired sheets from revit to autocad, for that I took 2 different dynamo, first one is to select sheets ( left part ) and the other part made by Konrad which exports the selected sheets in dwg.
Everything works perfectly fine except that the dwg I have is in IndexColor meaning everything is in Pink making it worthless.
Does any one of you know how to add a command in the code to change the settings of export from IndexColor to TrueColor ? Or else maybe to select a predefined export setup ?
(I tried a lot of things in the command with “ExportColorMode.TrueColor” or “SetDWGExportOptions()” but nothing worked out)
Hope my English wasn’t too bad, French student here.
# Copyright(c) 2016, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net
# Import Element wrapper extension methods
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
import System
from System.Collections.Generic import *
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN
def ProcessList(_func, _list):
return map( lambda x: ProcessList(_func, x) if type(x)==list else _func(x), _list )
def ProcessParallelLists(_func, *lists):
return map( lambda *xs: ProcessParallelLists(_func, *xs) if all(type(x) is list for x in xs) else _func(*xs), *lists )
def Unwrap(item):
return UnwrapElement(item)
folderPath = IN[0]
if isinstance(IN[1], list):
views = ProcessList(Unwrap, IN[1])
else:
views = list(Unwrap(IN[1]))
if isinstance(IN[2], list):
names = IN[2]
else:
names = list(IN[2])
RunIt = IN[4]
def ExportDwg(name, view, folder = folderPath):
options = DWGExportOptions()
options.MergedViews = IN[3]
views = List[ElementId]()
views.Add(view.Id)
result = doc.Export(folder, name, views, options)
return result
if RunIt:
try:
errorReport = None
# run export
ProcessParallelLists(ExportDwg, names, views)
except:
# if error accurs anywhere in the process catch it
import traceback
errorReport = traceback.format_exc()
else:
errorReport = "Please set the RunIt to True!"
#Assign your output to the OUT variable
if errorReport == None:
OUT = 0
else:
OUT = errorReport
# Copyright(c) 2016, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net
# Import Element wrapper extension methods
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
import System
from System.Collections.Generic import *
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN
def ProcessList(_func, _list):
return map( lambda x: ProcessList(_func, x) if type(x)==list else _func(x), _list )
def ProcessParallelLists(_func, *lists):
return map( lambda *xs: ProcessParallelLists(_func, *xs) if all(type(x) is list for x in xs) else _func(*xs), *lists )
def Unwrap(item):
return UnwrapElement(item)
folderPath = IN[0]
if isinstance(IN[1], list):
views = ProcessList(Unwrap, IN[1])
else:
views = list(Unwrap(IN[1]))
if isinstance(IN[2], list):
names = IN[2]
else:
names = list(IN[2])
RunIt = IN[4]
def ExportDwg(name, view, folder = folderPath):
options = DWGExportOptions()
options.MergedViews = IN[3]
options.Colors = options.Colors.TrueColor
views = List[ElementId]()
views.Add(view.Id)
result = doc.Export(folder, name, views, options)
return result
if RunIt:
try:
errorReport = None
# run export
ProcessParallelLists(ExportDwg, names, views)
except:
# if error accurs anywhere in the process catch it
import traceback
errorReport = traceback.format_exc()
else:
errorReport = "Please set the RunIt to True!"
#Assign your output to the OUT variable
if errorReport == None:
OUT = 0
else:
OUT = errorReport
Thanks for your reply, it actually worked, thing is, now when I export through Dynamo, Dynamo takes the “in-session export settings” with TrueColor and not My settings that I have configured before which creates some ugly stuff once in autocad.
Basically i tried something like this but the code doesn’t respond at all.
Dont have time to try this in revit/dynamo, but it should be sth like this:
SetDWGExportOptions(options.GetPredefinedOptions(doc,“dwg_export_template_name_as_string”))
Thanks for your reply again, and sorry to bother you once again, maybe I get it wrong but when i add your line code to my script it does nothing :
I switched : SetDWGExportOptions(options.GetPredefinedOptions(doc,“dwg_export_template_name_as_string”))
to: SetDWGExportOptions(options.GetPredefinedOptions(doc,Export_HVAC))
# Copyright(c) 2016, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net
# Import Element wrapper extension methods
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
import System
from System.Collections.Generic import *
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN
def ProcessList(_func, _list):
return map( lambda x: ProcessList(_func, x) if type(x)==list else _func(x), _list )
def ProcessParallelLists(_func, *lists):
return map( lambda *xs: ProcessParallelLists(_func, *xs) if all(type(x) is list for x in xs) else _func(*xs), *lists )
def Unwrap(item):
return UnwrapElement(item)
folderPath = IN[0]
if isinstance(IN[1], list):
views = ProcessList(Unwrap, IN[1])
else:
views = list(Unwrap(IN[1]))
if isinstance(IN[2], list):
names = IN[2]
else:
names = list(IN[2])
RunIt = IN[4]
def ExportDwg(name, view, folder = folderPath):
options = DWGExportOptions()
options.MergedViews = IN[3]
options.Colors = options.Colors.TrueColor
# '1' = dwg export settings name
options = options.GetPredefinedOptions(doc,'1')
views = List[ElementId]()
views.Add(view.Id)
result = doc.Export(folder, name, views, options)
return result
if RunIt:
try:
errorReport = None
# run export
ProcessParallelLists(ExportDwg, names, views)
except:
# if error accurs anywhere in the process catch it
import traceback
errorReport = traceback.format_exc()
else:
errorReport = "Please set the RunIt to True!"
#Assign your output to the OUT variable
if errorReport == None:
OUT = 0
else:
OUT = errorReport