it’s a PythonNet2.5 (CPython3) bug (use the getter method get_Name() instead)
# Load the Python Standard and DesignScript Libraries
import sys
import clr
import System
clr.AddReference('ProtoGeometry')
import Autodesk.DesignScript.Geometry as DS
# Import necessary Revit libraries
clr.AddReference('RevitAPI')
import Autodesk
import Autodesk.Revit.DB as DB
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
# Import DynamoServices for workspace information
clr.AddReference("DynamoServices")
from Dynamo.Events import *
# Access to the current Dynamo workspace path (e.g., location of the opened dynamo file)
currentWorkspacePath = ExecutionEvents.ActiveSession.CurrentWorkspacePath
currentWorkspace = ExecutionEvents.ActiveSession.CurrentWorkspacePath
directoryScript = System.IO.Path.GetDirectoryName(currentWorkspace)
#sys.path.append(directoryScript)
# sys.path.append(r"C:\Users\<user>\Downloads\netdxf.netstandard.3.0.1.nupkg\lib\netstandard2.0")
sys.path.append(r"D:\dy___Script x VE_CLEAN_2025-09-15\DWG_2025-09-23\package\netdxf.netstandard.3.0.1\lib\netstandard2.0")
# Import netDxf library for working with DXF files
clr.AddReference('netDxf.netstandard')
import netDxf
from netDxf import *
from netDxf.Blocks import *
from netDxf.Collections import *
from netDxf.Entities import *
from netDxf.Tables import *
# Define a class for working with DXF files
class DXF_Utils():
def __init__(self, outDxfpath):
self.outDxfpath = outDxfpath
self._doc_dxf = None
# Check if the DXF file exists, and if so, load it
if System.IO.File.Exists(self.outDxfpath):
# Initialize Document
self._doc_dxf = DxfDocument()
self._doc_dxf = netDxf.DxfDocument.Load(self.outDxfpath)
# Method to get all insert blocks with a specific attribute tag
def GetAll_Insert_Blocks(self, searchTag=""):
out = []
for e in self._doc_dxf.Inserts:
# Check if the block has the specified attribute tag
att_Test = e.Attributes.AttributeWithTag(searchTag)
if att_Test is not None:
# Create a DesignScript point from the DXF insert position
pt = DS.Point.ByCoordinates(e.Position.X, e.Position.Y, e.Position.Z)
out.append([e.Block.Name, pt, att_Test.Tag, att_Test.Value])
return out
# Unwrap the imported DXF element
import_inst_dxf = UnwrapElement(IN[0])
cadLinkType = doc.GetElement(import_inst_dxf.GetTypeId())
# Check if the linked CAD file is a DXF file
if cadLinkType.get_Name().endswith(".dxf"):
# Get the file path of the linked DXF file
ext_fileRef = cadLinkType.GetExternalFileReference()
modelpath_dxf = ext_fileRef.GetAbsolutePath()
dxf_filepath = DB.ModelPathUtils.ConvertModelPathToUserVisiblePath(modelpath_dxf)
# Create an instance of DXF_Utils class and get all insert blocks with a specific attribute tag
obj_dxf = DXF_Utils(dxf_filepath)
OUT = obj_dxf.GetAll_Insert_Blocks(searchTag="ATT_1")
Hi @c.poupin , great news — the get_Name() function is working as expected!
However, I’m still encountering an error with the method def GetAll_Insert_Blocks(self, searchTag=""):.
Thanks in advance for your help.
Cheers, and have a great day!
try with IronPython2 or IronPython3 with this code
# Load the Python Standard and DesignScript Libraries
import sys
import clr
import System
clr.AddReference('ProtoGeometry')
import Autodesk.DesignScript.Geometry as DS
# Import necessary Revit libraries
clr.AddReference('RevitAPI')
import Autodesk
import Autodesk.Revit.DB as DB
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
# Import DynamoServices for workspace information
clr.AddReference("DynamoServices")
from Dynamo.Events import *
# Access to the current Dynamo workspace path (e.g., location of the opened dynamo file)
currentWorkspacePath = ExecutionEvents.ActiveSession.CurrentWorkspacePath
currentWorkspace = ExecutionEvents.ActiveSession.CurrentWorkspacePath
directoryScript = System.IO.Path.GetDirectoryName(currentWorkspace)
#sys.path.append(directoryScript)
sys.path.append(r"C:\Users\sneep\Downloads\netdxf.netstandard.3.0.1.nupkg\lib\netstandard2.0")
# Import netDxf library for working with DXF files
clr.AddReference('netDxf.netstandard')
import netDxf
from netDxf import *
from netDxf.Blocks import *
from netDxf.Collections import *
from netDxf.Entities import *
from netDxf.Tables import *
# Define a class for working with DXF files
class DXF_Utils():
def __init__(self, outDxfpath):
self.outDxfpath = outDxfpath
self._doc_dxf = None
# Check if the DXF file exists, and if so, load it
if System.IO.File.Exists(self.outDxfpath):
# Initialize Document
self._doc_dxf = DxfDocument()
self._doc_dxf = netDxf.DxfDocument.Load(self.outDxfpath)
# Method to get all insert blocks with a specific attribute tag
def GetAll_Insert_Blocks(self, searchTag=""):
out = []
for e in self._doc_dxf.Inserts:
# Check if the block has the specified attribute tag
att_Test = e.Attributes.AttributeWithTag(searchTag)
if att_Test is not None:
# Create a DesignScript point from the DXF insert position
pt = DS.Point.ByCoordinates(e.Position.X, e.Position.Y, e.Position.Z)
out.append([e.Block.Name, pt, att_Test.Tag, att_Test.Value])
return out
# Unwrap the imported DXF element
import_inst_dxf = UnwrapElement(IN[0])
cadLinkType = doc.GetElement(import_inst_dxf.GetTypeId())
# Check if the linked CAD file is a DXF file
if cadLinkType.ToDSType(False).Name.endswith(".dxf"):
# Get the file path of the linked DXF file
ext_fileRef = cadLinkType.GetExternalFileReference()
modelpath_dxf = ext_fileRef.GetAbsolutePath()
dxf_filepath = DB.ModelPathUtils.ConvertModelPathToUserVisiblePath(modelpath_dxf)
# Create an instance of DXF_Utils class and get all insert blocks with a specific attribute tag
obj_dxf = DXF_Utils(dxf_filepath)
OUT = obj_dxf.GetAll_Insert_Blocks(searchTag="ATT_1")