Copy multiple DXF's to DWG

i’m reviewing a couple api options and i’m wanting to know if it is capable to copy multiple dxf entities(objects and misc. blocks) into a dwg.

what i need to do for each DXF:

gather the entities and blocks

open the dwg, paste the entities and blocks in a new location in model space(drawing size + 1/2" or so)
generate a new layout around the inserted objects. name the layer the name of the dxf file(ie column1)
update insert location and then do the same thing for the next dxf. i could have anywhere from 20 to hundreds of dxf’s to do this to.

some things of note: all dxf’s have the same layers and object types. we’re simply trying to reduce a workflow.

currently the drafter opens every file and copies the data manually. i’m trying to remove this from the workflow.

@Jefferydclark,
Hi.
Could you please prepare and attach here couple of initial DXF files and the example of desired merged DWG, so we can look at this visually and try what we can do. You can find also this thread helpful probably.

1 Like

i should note that i do not want to xref anything. as far as i’m aware you cannot xref DXF files. so what i guess needs to happen is to somehow open the dxf file, explode the blocks, then take all the objects and add them to the dwg file. if thats not possible could we get all the entities out of the block and then paste those entities to another file?

i tried attaching 2 dxf and 1 dwg but it says they cant be attached.

@Jefferydclark,
we can not explode the block. Grabbing entities from block is possible, but it is not clear if this is enough. Copy pasting entities to other file is likely possible but we need to preserve somehow the unique handles for each of them in new file. We hope a lot of other details related to the specific internal structure of DXF/DWG will be more clear after we investigate the examples of files, that’s why we are asking them :slight_smile: You can attach them here in zip format or use some third-party storage and post link here so we can download.

1 Like

code example.zip (41.4 KB)

here you go.

there are 3 files. 2 dxf drawings. and 1 dwg drawing.

the end result is the content visually must match from the dxf into the dwg but the blocks do not have to remain. we then need to create a layout tab for each file copied into the dwg.

@Jefferydclark,
thank you, we have created investigation task CADNET-9786 and will come back with more information.

1 Like

@oleksii.gorokhovatskyi not to rush but do you know an ETA on when i may have some answers on this? 1 week, 2 weeks, longer?

@Jefferydclark,
we will provide more information on this during next couple days.

@Jefferydclark,
Hello.

So the common situation is as the following.
In the scope of the problem we can only copy inserts from DXF drawings to some DXF template now:
TestOutputTemplate.zip (15.7 KB)

string[] fileNames = new string[] { "DH-100.dxf", "DH-101.dxf" };
string template = "TestOutputTemplate.dxf";
string outPath = outDir + "TestOutputTemplateResult.dxf";

using (DxfImage cadImage = (DxfImage)Aspose.CAD.Image.Load(template))
{
 // get next available object ID to prevent collisions
 string newObjectID = ((CadStringParameter)cadImage.Header.HeaderProperties[CadHeaderAttribute.HANDSEED][0]).Value;

 Cad3DPoint maxPoint = new Cad3DPoint();

 foreach (string fileName in fileNames)
 {                 
     System.Console.WriteLine(fileName);

     using (CadImage dxfImage = (CadImage)Aspose.CAD.Image.Load(fileName))
     {
         foreach (CadEntityBase entity in dxfImage.Entities)
         {
             if (entity.TypeName == CadEntityTypeName.INSERT)
             {
                 CadInsertObject insert = (CadInsertObject)entity;

                 insert.InsertionPoint.X += maxPoint.X;
             }

             // replace its ID
             entity.ObjectHandle = newObjectID;

             cadImage.AddEntity(entity);

             newObjectID = (Convert.ToInt64(newObjectID, 16) + 1).ToString("X");
         }

         maxPoint.X += dxfImage.Width + 10;
     }
 }

 cadImage.UpdateSize();

 ((CadStringParameter)cadImage.Header.HeaderProperties[CadHeaderAttribute.HANDSEED][0]).Value = newObjectID;

 cadImage.Save(outPath);
}

We can not at the moment:

  • explode blocks (corresponding task CADNET-9796 was created to support this);
  • add layouts (corresponding task CADNET-9795 was created to implement this);
  • save the result DXF to DWG (should be fixed in the scope of CADNET-9763, we are already working with this issue).

We can now roughly evaluate the delivery time for these features as Q3 2024, but can not guarantee that (will be happy to deliver earlier though).

thanks for the response. i’d like to have something much sooner. i’ll check back if i dont have my project completed by then.

1 Like

@Jefferydclark,
got it, thank you.