1 Reply Latest reply on Sep 13, 2018 8:38 AM by Todd Carpenter

    Translating Model Points to Drawing Points

    Todd Carpenter

      I think I'm close, but since I keep going to the extreme right and then left, I'm missing an important step and I'm not quite sure what.  Given this drawing:

      I don't have any trouble getting the datum point PT_VERT, but converting it to a location I can stick the annotation on seems to be a real trick.  Here's the import part of the code, can someone tell me what I'm doing wrong?

       

                  boolstatus = swDoc.Extension.SelectByID2("RD1@Drawing View2", "DIMENSION", 0, 0, 0, false, 0, null, 0);
      
      
                  object AnnObj = SelMgr.GetSelectedObject6(1, -1);
                  DisplayDimension DispDim = (DisplayDimension)AnnObj;
                  Annotation swAnn = (Annotation)DispDim.GetAnnotation();
                  double[] oldloc = new double[3];
                  oldloc = (double[])swAnn.GetPosition();
      
      
                  //Point Information
                  boolstatus = swDoc.Extension.SelectByID2("PT_VERT@Widget-12@Drawing View1", "DATUMPOINT", 0, 0, 0, false, 0, null, 0);
      
      
                  Feature swFeat = default(Feature);
                  RefPoint swRefPt = default(RefPoint);
                  RefPointFeatureData swRefPtData = default(RefPointFeatureData);
                  MathPoint swMathPt = default(MathPoint);
                  
                  swFeat = (Feature)SelMgr.GetSelectedObject6(1, -1);
                  swRefPt = (RefPoint)swFeat.GetSpecificFeature2();
                  swRefPtData = (RefPointFeatureData)swFeat.GetDefinition();
      
      
                  swMathPt = (MathPoint)swRefPt.GetRefPoint();
                  double newXLoc = (((double[])swMathPt.ArrayData)[0] + posOutline[0]);
                  double newYLoc = (((double[])swMathPt.ArrayData)[1] + posOutline[1]);
                        
                  Debug.Print("   Dim = (" + oldloc[0] + ", " + oldloc[1] + ", " + oldloc[2] + ") m");
                  Debug.Print("NewDim = (" + newXLoc + ", " + newYLoc + ", 0.0) m");
                  Debug.Print("    Pt = (" + ((double[])swMathPt.ArrayData)[0] + ", " + ((double[])swMathPt.ArrayData)[1] + ", " + ((double[])swMathPt.ArrayData)[2] + ") m");
                  Debug.Print("  View = (" + posOutline[0] + ", " + posOutline[1] + ", " + "0.0) m");
      
      
                  swAnn.SetPosition2(newXLoc, newYLoc, 0.0);
                  swDoc.ClearSelection2(true);
      

       

      Thanks