You can also try the LinkDWG package which will allow you to pull data from an open AutoCAD drawing.
Data extraction also works.
You can also try the LinkDWG package which will allow you to pull data from an open AutoCAD drawing.
Data extraction also works.
Hey, I don’t know where you’re seeing that… could you post a screen shot?
Should be released by Monday
Where will this be released? Looking forward to it!
When I find the time! It’s passed testing and ready for release, just finishing off the obligatority documentation/announcment post.
You can find the text extraction nodes in BimorphNodes v3 available on the package manager - the node to use is CADTextData.FromLayers. More info here.
So I’ve followed this thread and I have converted CAD text to Revit text.
My question for is what is doing about the different sizes of text?
All my text is the same size and bigger than what I want and I have been trying to figure out how to change the type of text.
Text doesn’t appear to be in the ‘Family Types’ selection node.
I can get the text height from the CAD file and the text height of the text that Revit creates.
I just can’t set the type/height for each piece of text.
Appreciate any help.
Ok just to answer my own question.
I was able to figure it out. For some reason I kept trying to find a ‘family’ for the text, but there isn’t a family.
In the bottom left corner is where I’m using the ‘Element Types’ node to select “TextNoteType” then get a list of all the types. From there you just select the one you want and place it into the input of the ‘TextNote.ByLocation’ node.
Didn’t 100% work how I wanted it to, but get’s me a lot closer than manually typing it all in.
That is AutoLISP, a language not yet implemented in Dynamo. AutoLISP can be used to write out text files from AutoCAD, that can be read into Dynamo.
Hi @Thomas_Mahon do you have the code for this node available in your bimorph github? I like to know how to add the netdxf library, unless its a zero touch node which I think is C#
Adding the netDXF library is easy enough; simply install it via NuGet package manager in VS.
@Thomas_Mahon, how did you get raw CAD data from an ImportInstance object? Exporting the import instance to DXF seems tricky, could you possibly give us a hint how this can be achieved?
Hi Agnieszka if you don’t need text and are only after the geometry then you can use the Revit API for this. I’ve added a code snippet below - its not tested so you might need to adjust it as it was from a very old script in BimorphNodes V1.
If you are after text extraction there is no way to obtain it from the CAD file using the Revit API. You need to either export to DXF or look at alternatives like Grasshopper which I believe includes nodes to extract text from DWGs, or the AutoCAD API.
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
importDWG = UnwrapElement(IN[0])
nameOfLayersToImport = IN[1]
revitModelLines = IN[2]
if nameOfLayersToImport == None or nameOfLayersToImport == []:
catSub = importDWG.Category.SubCategories
enum = catSub.GetEnumerator()
nameOfLayersToImport = []
while enum.MoveNext():
layerName = enum.Current.Name
nameOfLayersToImport.Add( layerName )
if isinstance(nameOfLayersToImport, list):
layerList = nameOfLayersToImport
else:
layerList = [nameOfLayersToImport]
def storageDictionary(crvListDict, eleGraphicStyleName, e):
if eleGraphicStyleName in crvListDict.keys():
crvListDict[eleGraphicStyleName].append( e )
else:
crvListDict[eleGraphicStyleName] = []
crvListDict[eleGraphicStyleName].append( e )
def curveConversion (crv, revitModelLines, crvObject, refPlane):
if revitModelLines == True:
crv.Add( doc.Create.NewModelCurve( crvObject, refPlane) )
else:
crv.Add( crvObject.ToProtoType() )
TransactionManager.Instance.EnsureInTransaction(doc)
geomEnum = importDWG.Geometry[ Options() ].GetEnumerator()
crvListDict = dict()
failedFilter = []
while geomEnum.MoveNext():
instGeom = geomEnum.Current.GetInstanceGeometry()
instGeomEnum = instGeom.GetEnumerator()
while instGeomEnum.MoveNext():
e = instGeomEnum.Current
try:
graphicStyleId = e.GraphicsStyleId
eleGraphicStyle = doc.GetElement(graphicStyleId)
eleGraphicStyleName = eleGraphicStyle.GraphicsStyleCategory.Name
if eleGraphicStyleName in layerList:
storageDictionary(crvListDict, eleGraphicStyleName, e)
except:
try:
vol = e.Volume
if vol == 0.0:
edgesList = e.Edges
edgesEnum = edgesList.GetEnumerator()
while edgesEnum.MoveNext():
edge = edgesEnum.Current
eleGraphicStyle = doc.GetElement(edge.GraphicsStyleId)
eleGraphicStyleName = eleGraphicStyle.GraphicsStyleCategory.Name
if eleGraphicStyleName in layerList:
storageDictionary(crvListDict, eleGraphicStyleName, edge.AsCurve() )
except:
failedFilter.Add(e)
levelParam = BuiltInParameter.IMPORT_BASE_LEVEL
levelId = importDWG.Parameter[levelParam].AsElementId()
pln = SketchPlane.Create(doc, levelId )
crvList = [ crv for crv in crvListDict.values() ]
failedConversion = []
modelLines = []
for subList in crvList:
crv = []
for i in subList:
try:
crvType = i.GetType()
if crvType != Autodesk.Revit.DB.PolyLine:
curveConversion(crv, revitModelLines, i, pln)
else:
pt = i.GetCoordinates()
count = i.NumberOfCoordinates
for j in range(count-1):
ln = Line.CreateBound(pt[j], pt[j+1])
curveConversion(crv, revitModelLines, ln, pln)
except:
failedConversion.Add( i )
modelLines.Add(crv)
TransactionManager.Instance.TransactionTaskDone()
OUT = modelLines, crvListDict.keys()
Thanks for your reply! I need the texts, so I’m trying to do the DWG export to DXF through Revit API. I believe that the BimorphNode for text extraction somehow gets it done without accessing the original .dwg filepath
Yes thats correct, BimorphNodes does the following:
Its this DXF which is processed.
Thanks a million, that’s exactly what I was looking for!
This is the way I would go, via the ACDbMgd.dll
which ships with Revit (and I believe is accessible in the application context). Have you tried doing so?
Hi, are any of the source code for Bimorph nodes avaialble and/or open source? I’m able to use in Dynamo but can’t seem to access the code behind, for example, “Sheet.FromSchedule” Man that would be really helpful
Hi Kervin most of the source code is available in older versions of BimorphNodes written in Python, including Sheet.FromSchedule. If you download any v1.x.x version you can extract the code from the Python node.