[CE5 C#] DimStyleProp Alignment Problem

In VBA, to set the Alignment mode in DimensionStyle from "View" to "True", we use

DimensionStyle.Alignment = MsdDimAlignment.True

When we are in .NET API, we use:

DimensionStyle.SetIntegerProp(2, DimStyleProp.General_Alignment_INTEGER);

and apply it to DimensionCreateData.

However, the dimension element is not working as true alignment. What did I miss?

Parents Reply Children
  • Hi,

    thank you for providing the DGN example. From what I can see the position of handle1 seems to be off the correct position:

    Without knowing the code example used to create this dimension it is difficult to say what needs to be changed to obtain a better result.
    The "Fit Options" settings has influence in positioning the dimension text/terminator, do you get different results disabling fit:


    It would be great if could upload a testcase containing you source code which created this dimension element.
    For reference I have posted here a code example with title: "Create dimension element with true Alignment"

    Best regards,
    Artur

  • What I meant in last post was to use "move element" tool to move the dimension element, but not moving the handle of dimension element.

    You will finally see a correct shape in CE5 and incorrect shape in V8i.

    Thank you for your code example, compared with your example and I found that I didn't use:

    DTransform3d dtrans = new DTransform3d(dmat);
    TransformInfo transform = new TransformInfo(dtrans);
    dimElement.ApplyTransform(transform);
    On the other hand, I used this method to replace ApplyTransform
    dimElement.SetRotationMatrix(dmat);
    But SetRotationMatrix did not work as expected and generated a strange dimension element.
  • Unknown said:
    What I meant in last post was to use "move element" tool to move the dimension element, but not moving the handle of dimension element.

    Hi,

    I can see the different behavior with moving the element (not handle) between V8i and CONNECT. I just noticed the position of the handle before moving the element, and that´s not where I would expect it.
    But the resulting dimension element does not allow to determine what exactly caused the creation of this element without knowing the source code.
    Providing a test case containing the source code could help to understand this issue.

    Thanks,

    Artur

  • Unknown said:

    But the resulting dimension element does not allow to determine what exactly caused the creation of this element without knowing the source code.

    //<----Dimension--->
                DgnFile dgnFile = Session.Instance.GetActiveDgnFile();
                DgnModel dgnModel = Session.Instance.GetActiveDgnModel();
                DimensionStyle oDimStyle = DimensionStyle.GetSettings(dgnFile);
                DgnTextStyle txtStyle = DgnTextStyle.GetSettings(dgnFile);           
                LevelHandle levelHandle = dgnFile.GetLevelCache().GetLevelByName('Default');
                Symbology symb = new Symbology();
                DirectionFormatter dirFormatter = new DirectionFormatter(dgnModel);
    
                oDimStyle.SetIntegerProp(2, DimStyleProp.General_Alignment_INTEGER);
                oDimStyle.SetBooleanProp(true, DimStyleProp.ExtensionLine_ShowAny_BOOLINT);
                oDimStyle.Replace(null, null);
                DimensionCreateData DimensionCreateData = new DimensionCreateData(oDimStyle, txtStyle, symb, levelHandle.LevelId, dirFormatter);
                DimensionElement dimEle = new DimensionElement(dgnModel, DimensionCreateData, DimensionType.SizeArrow);
    
                //Set Rotation
                double a = Math.Atan2(Converts.ToUOR(1000), Converts.ToUOR(1000));
                DMatrix3d oMatrix = new DMatrix3d(Math.Cos(a), Math.Sin(a), 0, Math.Sin(a), Math.Cos(a), 0, 0, 0, 1);
                dimEle.SetRotationMatrix(oMatrix);
    
                //Set dimension Points
                dimEle.InsertPoint(calc.TranslateD(0, 0, 0), null, oDimStyle, 0);
                dimEle.InsertPoint(calc.TranslateD(Converts.ToUOR(1000), Converts.ToUOR(1000), 0), null, oDimStyle, 1);
                dimEle.SetHeight(Converts.ToUOR(500));
                dimEle.ApplyDimensionStyle(oDimStyle, true);
                dimEle.AddToModel();
    



    As I have not solved how to get the active dimension style's parameters (when no external dimension style created), with these code and a new dgn file you may generate a error dimension element with error parameter.


    or like this



    Just use the previously uploaded dgn to prevent this kind of unknown errors.