Link cad from background to foreground

Thanks for all the help, i can link a cad file and find a specific file. Maybe there’s a way to do with all views at the same time, but for me works great! The link cad is place in the right view, but i want to change the draw layer by default its background. How can I do that from this dynamo routine?

You can write a python script set parameter like this with importInstance is a element input

1 Like

thanks a lot…with my actual knowledge I don’t know how to do that, but I´ll try!


You can see script sample below :

import sys
import clr
from Autodesk.DesignScript.Geometry import *
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
#Do some action in a Transaction
#Do Action
importInstance = UnwrapElement(IN[0])
val = IN[1]
OUT = 0

settogglebg.dyn (6.0 KB)

1 Like

Thanks again, the node works great. Now I need to run the script not with “select model Element” but use the “link DWG” node.
if you look at the image, “ImportInstance” creates the element inside Revit, I guess I could link this element with the script, so that everything is done from Dynamo:

Find the file in the directory
Put this this file in the selected view
The linked cad file is on Foreground


I integrated this new option in the Link DWG custom node.
link dwg


Thanks a lot!!! Works great

I tried to use the Link DWG node in Revit 2023 but doesn’t have the Draw layer option. What can i do?

Thanks a lot


Your version of the Genius Loci package in Dynamo 2.13 is probably not up to date.

1 Like

Thanks. Works again

I normally don’t hijack a closed post, however my issue is relevant to what is discussed herein. I am getting an error with the Import DWG node or at least it’s not working in 2022 nor 2023. I have the latest version of the Genius Loci package 2022.9.16 installed. Yet the node doesn’t work. After researching it looks like there has been a change in the Revit API. The CLR module no longer contains the attribute “Reference”. So this part of the code is failing.



It is working fine in Revit 2023.

Be sure to have the DynamoIronPython2.7 package installed.

Okay. So not sure what was going on, but the updated node wasn’t getting loaded in, but reloaded the package and the updated node is getting loaded now. However, I am getting a Function return from the node. I believe I have all required inputs covered, so not sure what is causing the error.

Delete the old Import DWG node and replace it.
Or right click on the new document input and enable Default value.

Works like a charm now. Thank you for the quick responses!!