Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Holzethekid
in reply to: Holzethekid

Hall Theo,

thanks for the anwer. But as you mentioned the 'PromoteParameter' does not work.

I 'found' a  really sketchy solution how to identify a annotation depending on a DimensionConstraint.

 

I guess that this solution will be very easy to break, and if the other objects 

- RadiusModelDimensions

- DiameterModelDimensions

- AngularModelDimensions

will work the same way ?? I don't know

 

 

  public ModelAnnotation GetConnectedAnnotation(DimensionConstraint constraint)
        {
            logger.Debug($"GetConnectedAnnotation");

            var annotations = applicationService.GetDocumentAnnotations();

            foreach (var md in annotations.ModelDimensions)
            {
                if (md is LinearModelDimension modelDimension)
                {
                    if (modelDimension.Definition is LinearModelDimensionDefinition lmdd)
                    {
                        if (lmdd.IntentOne.Geometry is SketchPoint sp)
                        {
                            foreach (var point in constraint.AnchorPoints)
                            {
                                if (point is Point2d point2d)
                                {
                                    if (sp.Geometry.IsEqualTo(point2d))
                                    {
                                        if (Math.Abs(constraint._DisplayValue - modelDimension.ModelValue) <= 0)
                                        {
                                            logger.Debug($"found constraint : {constraint.Parameter.Name} Value:'{constraint.Parameter.Expression}' | modelDimesnion{modelDimension.Name} Value :'{modelDimension.ModelValue}'");
                                            return md as ModelAnnotation;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return null;
        }