moving files to new position

1
Jose Oscar Samper
2/19/2022 4:57 PM

Regards.

I have two files and I want to save them in a third one by moving each of these to a certain position and saving it in another file.

the first translation does it well but the second does not (it makes the translation very far away).

Attached code and autocad files.

Can you tell me what I'm doing wrong?

Thanks in advance.

C# Code:
            DxfModel card_model = null;
            
            DxfModel poligono_model = null;


            card_model = CadReader.Read("C:\\backup\\PLANO_INDIVIDUAL.dwg", true);

            poligono_model = CadReader.Read("C:\\backup\\Poligono.dwg", true);

            DxfModel target = new DxfModel(poligono_model.Header.AcadVersion);
            TransformConfig transformConfig = new TransformConfig();

           
            double x = 10;
            double y = 10;
            
            transformConfig = new TransformConfig();

            //traslada el dibujo
            Matrix4D transform = Transformation4D.Translation(x, y, 0);
            foreach (DxfEntity entity in card_model.Entities)
            {
                entity.TransformMe(transformConfig, transform);
            }


            //clona el dibujo   en destino
            CloneContext cloneContext = new CloneContext(card_model, target, ReferenceResolutionType.CloneMissing);
            foreach (var selectedEntity in card_model.Entities)
            {
                DxfEntity clonedEntity = (DxfEntity)selectedEntity.Clone(cloneContext);
                target.Entities.Add(clonedEntity);
            }
            cloneContext.ResolveReferences();

            x = 1;
            y = 1;

            // traslada el dibujo
            transformConfig = new TransformConfig();
            transform = Transformation4D.Translation(x, y, 0);
            foreach (DxfEntity entity in poligono_model.Entities)
            {
                entity.TransformMe(transformConfig, transform);
            }


            // traslada el dibujo
            cloneContext = new CloneContext(poligono_model, target, ReferenceResolutionType.CloneMissing);
            foreach (var selectedEntity in poligono_model.Entities)
            {
                DxfEntity clonedEntity = (DxfEntity)selectedEntity.Clone(cloneContext);
                target.Entities.Add(clonedEntity);
            }
            cloneContext.ResolveReferences();

            //GuardarDatos el archivo
            DwgWriter.Write("C:\\backup\\Nuevo.dwg", target);

Wout
2/19/2022 5:58 PM

Hi,

If you found a CadLib bug I will gladly look into this, but other than that I will not debug client software.

- Wout

1