Page 1 of 1

How to use Dimension Styles

Posted: 27 Nov 2009, 00:13
by aby
Hi,
I've uploaded a dwg file which contains my default dimension style.

In the following I'm trying to use Dimension Styles and try to give a dimension.

It seems it is not using the dimension Style.

What am I missing?

Thanks

Aby

Code: Select all

        FDwgNavigator = new TSGDrawingNavigator(FForm);
        FDwgNavigator->Parent = FForm;
        FDwgNavigator->Align = alClient;
        FDwgNavigator->AutoFocus = true;
        FDwgNavigator->Anchors = FDwgNavigator->Anchors << akLeft << akTop << akRight << akBottom;
        FDwgNavigator->Picture->Graphic = NULL;

        FDwgNavigator->Update();
        FDwgNavigator->LoadFromFile(ResFileName);
        FCADImage = dynamic_cast<TsgDXFImage *> (FDwgNavigator->Picture->Graphic);
        FCADImage->BackgroundColor = clBlack;
        FCADImage->DefaultColor = clWhite;
        FDXFConverter = FCADImage->Converter;
        if (FCADImage->SelectionMatrix == NULL)
                FCADImage->SelectionMatrix = new TsgSelectionMatrix();
        FCADImage = dynamic_cast<TsgCADImage *> (FDwgNavigator->Picture->Graphic);
        FCADImage->SetMatrixMode(smEnabled);
        FCADImage->GetExtents();
        TsgDXFDimension *ProDim = NULL;
        for (int I = 0; I < FDXFConverter->Counts[csEntities]; ++I) {
                ProDim = dynamic_cast<TsgDXFDimension *> (FDXFConverter->Entities[I]);
                if (ProDim) break;
        }
        FForm->Show();
       
        TsgDXFDimension *sgDms = new  TsgDXFDimension;

//        sgDms->AssignEntity(ProDim); // This is not working Should'nt have to work? 

     
        sgDms->Flags = 0;
        sgDms->LinDefPoint1 = MakeFPoint(0,0,0);
        sgDms->LinDefPoint2 = MakeFPoint(100,0,0);
        sgDms->DefPoint = MakeFPoint(100,-25,0);
        sgDms->Style = ProDim->Style;
        sgDms->TextStyle = ProDim->TextStyle;
        sgDms->Layer = ProDim->Layer;
        FCADImage->CurrentLayout->AddEntity(sgDms);
        FCADImage->Converter->Loads(sgDms);
        FCADImage->RefreshCurrentLayout();
        FCADImage->GetExtents();



Re: How to use Dimension Styles

Posted: 03 Dec 2009, 12:53
by aby
Hi,

My two cents. The issue may be is coming from setting AutoCad drawing system variables.
How can I set AutoCad system Variables with your library, in example DIMTSZ.

Aby

Re: How to use Dimension Styles

Posted: 03 Dec 2009, 16:50
by support
Hello.
You need to load your new TsgDXFDimension entities into Converter:

Code: Select all

  ...
  FCADImage->Converter->Loads(ProDim);
  FCADImage->Converter->Loads(sgDms);
  sgDms->AssignEntity(ProDim);
  ...
Alexander.

Re: How to use Dimension Styles

Posted: 04 Dec 2009, 00:01
by aby
Hi,

"You need to load your new TsgDXFDimension entities into Converter"
FCADImage->Converter->Loads(ProDim);
FCADImage->Converter->Loads(sgDms);
sgDms->AssignEntity(ProDim);"

I did it like you suggested but the issue is not solved.

If you load or not the new TsgDXFDimension entities into Converter is not making any difference.

Wheen I push the Button1 I can not see on the screen, the new dimension that supposed to be created.

I have exported to a file the current situation. Opened in AutoCad.

Enter a move command.

Select the dimension entites.

It is selecting 2 entities. The newly created is duplicated it is residing onto the first one.

When I list the 2 entities, the last dimension text line coordinates equals to the first one.

enter remove select the top entity, then move the entity where ever you want.

The new Dim is appearing without text, the oblique tick is changing to arrows.

Here is the code. Could you test on Delphi side this issue with the test.dwg that I've sent.

Code: Select all

void __fastcall TCadManager::Button1Click(TObject *Sender)
{
                
        TsgDXFDimension *sgDms = new  TsgDXFDimension;
        FCADImage->Converter->Loads(sgDms);
        sgDms->AssignEntity(ProDim);

        sgDms->Flags = 0;
        sgDms->LinDefPoint1 = MakeFPoint(0,0,0);
        sgDms->LinDefPoint2 = MakeFPoint(100,0,0);
        sgDms->DefPoint = MakeFPoint(100,-25,0);
        sgDms->Style = ProDim->Style;
        sgDms->TextStyle = ProDim->TextStyle;
        sgDms->Layer = ProDim->Layer;
        FCADImage->CurrentLayout->AddEntity(sgDms);
        FCADImage->Converter->Loads(sgDms);
        FCADImage->RefreshCurrentLayout();
        FCADImage->GetExtents();
        TGraphic *vGr =(FDwgNavigator->Picture->Graphic);
        int vWidth = vGr->Width;
        int vHeight = vGr->Height;
        double vRatio = (vHeight) ? (double)vWidth / vHeight : 1.0;
        if (vRatio <= 1.0) {
                vHeight = Screen->Height;
                vWidth = Ceil(vHeight * vRatio);
        } else {
                vWidth = Screen->Width;
                vHeight = Ceil(vWidth / vRatio);
        }
        TsgCADtoDXF *ExpCadFile(new TsgCADtoDXF( dynamic_cast<TsgDXFImage *> (vGr)));
        ExpCadFile->SaveToFile(FResFileName);

}

Re: How to use Dimension Styles

Posted: 04 Dec 2009, 12:16
by support
Hello.
The problem is not in the absence of copying dimension style. And it seems you didn't missed anything. Dimension object is copied with style, but style, created by our lib, looks a bit different from AutoCAD. We will resolve this problem.

Alexander.