Page 1 of 1

Save CADInsert in DXF not work

Posted: 13 Nov 2018, 16:02
by coo5hda
Hello,
I am adding several CADPolylines in a CADBlock and this last one I add it to a CADInsert which I charge to the CADEditorControl.Image however, when I want to save the elements stored in the CADInsert in DXF format, it does not store the elements nor the CADInsert

Re: Save CADInsert in DXF not work

Posted: 13 Nov 2018, 18:45
by support
Hello,

The elements (CADPolylines in the given case) are actually stored in a CADBlock, not in a CADInsert. CADInsert just refers to the CADBlock through a CADInsert.Block property.

Could you please post your code which creates a CADBlock and CADInsert and adds these objects to a CADEditorControl.Image? We will check it.

Mikhail

Re: Save CADInsert in DXF not work

Posted: 13 Nov 2018, 19:11
by coo5hda

Code: Select all

        private bool PlaceEntity(CADEntity aEntity)
        {
            return PlaceEntity(aEntity, "");
        }

        private bool PlaceEntity(CADEntity aEntity, string aLayoutName)
        {
            CADLayout vLayout;
            if (aLayoutName == "")
                vLayout = editor.Image.Layouts[0];
            else
                vLayout = editor.Image.Converter.LayoutByName(aLayoutName);

            if (vLayout == null) return false;

            editor.Image.Converter.Loads(aEntity);
            vLayout.AddEntity(aEntity);

            return true;
        }

        private void DrawDoriArea(DPoint point)
        {
            CADBlock block = new CADBlock();
            block.Name = "blockDoriArea";

            block.AddEntity(DrawCamera(point));
            block.AddEntity(DrawLens(point));
            block.AddEntity(DrawIdentificationArea(point));
            block.AddEntity(DrawRecognitionArea(point));
            block.AddEntity(DrawObservationArea(point));
            block.AddEntity(DrawDetectionArea(point));
            block.AddEntity(DrawArc(point));

            CADInsert insert = new CADInsert();
            insert.Block = block;

            if (!PlaceEntity(insert))
                editor.Image.Converter.GetSection(ConvSection.Blocks).RemoveEntityByName("blockDoriArea");
        }
this is the code

Re: Save CADInsert in DXF not work

Posted: 13 Nov 2018, 20:05
by support
There are two problems in your code:

1) You didn't add the CADBlock to the BLOCKS section, the following code is missing:

Code: Select all

        private void AddEntToSection(ConvSection aSection, CADEntity aEntity)
        {
            editor.Image.Converter.Loads(aEntity);
            editor.Image.Converter.GetSection(aSection).AddEntity(aEntity);
        }

            ...
            
            CADBlock block = new CADBlock();
            block.Name = "blockDoriArea";
            AddEntToSection(ConvSection.Blocks, block);
2) The CADInsert must have the insertion point, the following code is missing:

Code: Select all

insert.Point = new DPoint(0, 0, 0);
Mikhail

Re: Save CADInsert in DXF not work

Posted: 13 Nov 2018, 20:44
by coo5hda
This point is always (0,0,0)?

Re: Save CADInsert in DXF not work

Posted: 13 Nov 2018, 22:14
by support
coo5hda wrote:
13 Nov 2018, 20:44
This point is always (0,0,0)?
No, you can use any (X,Y,Z) value, depending on where you want to place the CADInsert object. (0, 0, 0) is just an example.

Mikhail