Export embeded data into a DXF

So, I want to embed some strings into a DXF as a DXF Attribute Tag during export…

Anyone have any experience with such a thing?

I am running visual studio and using rhinocommon and the rhinoscriptsyntax dll in VB

Thanks :slight_smile:

There is a package for reading and writing .dxf files freely available here -

We have used this to create and write a DXF from scratch, but I think it should also be possible to open a DXF, add some strings to the definition and write it.

Thanks.

I know it sounds crazy… I’ll explain it.

My work uses SigmaNest. Sigmanest can auto-fill part info fields with two methods. String tags and attribute tags.
A string tag will work. That is just a TextObject that is next to the part during dxf export. But they don’t want that. They only want the part dxf by itself. Not sure why… as sigmanest see’s that as tags only and does not make those textobjects part of the cnc tooling paths. It just sees it as pure data. But… they don’t want it that way.
I think they are thinking about the cad designers. I don’t think they want them filling out tag info for every single part. But I have not explained to them that I can add textobjects at runtime before the dxf export, export, then delete them from the drawing. I’ll bring that up on Monday.

Then that leaves me with attribute tags… which I have explained to them… rhino does not use. (Think autocad block attributes)

So now I have two options left. Manually insert attributes into the dxf code or write a sigmanest plugin to play along with my rhino plugin I made.

This is a pain lol.

So i have been playing around with dxfNET…

I cant seem to get it.

I have this so far.

Dim dxfLoad = DxfDocument.Load("C:\Users\Alan\Documents\DXF Parts\1.dxf")
Dim attDef = New netDxf.Entities.AttributeDefinition("REMARK:TEST")
Dim entity = New netDxf.Entities.Attribute(attDef)

dxfLoad.AddEntity(entity)
dxfLoad.Save("C:\Users\Alan\Documents\DXF Parts\1.dxf")

Any thoughts?

Ok… so I am getting it… sort of

        Dim dxfLoad = DxfDocument.Load("C:\Users\Alan\Documents\DXF Parts\1.dxf")
        Dim block = New Block("Test")
        Dim ad1 = New AttributeDefinition("REMARK:")
        block.AttributeDefinitions.Add(ad1)
        block.AttributeDefinitions("REMARK:").Value = "HelloWorld"
        Dim insert = New Insert(DirectCast(block.Clone(), Block))
        insert.Sync()

        dxfLoad.AddEntity(insert)
        dxfLoad.Save("C:\Users\Alan\Documents\DXF Parts\1.dxf")

But it seems to clear the whole dxf file now :cry:

If you don’t add the attribute, but just write the DXF as it was, is it also cleared? What I mean is, is adding an attribute the cause of clearing the whole document?

Could you put the text object on a layer, and delete that layer before export?

I got it now.

I was opening the wrong dxf in sigmanest lol.

It works perfect.

Then only thing I noticed, is that rhino also exports the object WITH xyz coords.

Not a big deal really.

Thanks for the tip on using netDXF :slight_smile:

and cdordoni, if you delete the textobject before you export, then it wouldn’t export :stuck_out_tongue:

Ah, I misunderstood, sounded like you did not want the text objects to be in the file that the cad designers open for editing.