Beispiel #1
0
        public static bool GetObjectAttribute(DisplayableObject singleObj, out ObjectAttribute sObjectAttribute)
        {
            sObjectAttribute = new ObjectAttribute();
            try
            {
                //取得Non-SelfCheck的Excel屬性
                try { sObjectAttribute.singleObjExcel = singleObj.GetStringAttribute(CaxME.DimenAttr.AssignExcelType); }
                catch (System.Exception ex) { sObjectAttribute.singleObjExcel = ""; }

                //取得SelfCheck的Excel屬性
                try { sObjectAttribute.singleSelfCheckExcel = singleObj.GetStringAttribute(CaxME.DimenAttr.SelfCheckExcel); }
                catch (System.Exception ex) { sObjectAttribute.singleSelfCheckExcel = ""; }

                //取得keyChara、productName、customerBalloon、SPCControl
                try { sObjectAttribute.keyChara = singleObj.GetStringAttribute(CaxME.DimenAttr.KC); }
                catch (System.Exception ex) { sObjectAttribute.keyChara = ""; }

                try { sObjectAttribute.productName = singleObj.GetStringAttribute(CaxME.DimenAttr.Product); }
                catch (System.Exception ex) { sObjectAttribute.productName = ""; }

                try { sObjectAttribute.customerBalloon = singleObj.GetStringAttribute(CaxME.DimenAttr.CustomerBalloon); }
                catch (System.Exception ex) { sObjectAttribute.customerBalloon = ""; }

                try { sObjectAttribute.spcControl = singleObj.GetStringAttribute(CaxME.DimenAttr.SpcControl); }
                catch (System.Exception ex) { sObjectAttribute.spcControl = ""; }
            }
            catch (System.Exception ex)
            {
                return(false);
            }
            return(true);
        }
Beispiel #2
0
    public void hideit(NXObject objtohide)//////这是一个隐藏NXObject的方法
    {
        DisplayableObject a = (DisplayableObject)objtohide;

        DisplayableObject[] objects1 = new DisplayableObject[1];
        objects1[0] = a;
        theSession.DisplayManager.BlankObjects(objects1);
    }
Beispiel #3
0
 //------------------------------------------------------------------------------
 //Callback Name: update_cb
 //------------------------------------------------------------------------------
 public int update_cb(NXOpen.BlockStyler.UIBlock block)
 {
     try
     {
         if (block == selectionBody)
         {
             //---------Enter your code here-----------
             if (points.Count > 0)
             {
                 DeleteObject.Delete(points.ToArray());
             }
             points.Clear();
             foreach (TaggedObject tobj in selectionBody.GetSelectedObjects())
             {
                 if (tobj is DisplayableObject && !(tobj is CoordinateSystem))
                 {
                     DisplayableObject disp = tobj as DisplayableObject;
                     nxObjects.Add(tobj as NXObject);
                     disp.Highlight();
                 }
             }
             this.aoo = new NXObjectAooearancePoint(nxObjects.ToArray());
             points   = aoo.CreatePoint();
         }
         else if (block == get_point)
         {
             // ---------Enter your code here---------- -
             Point3d temp = this.GetPoint();
             if (this.selectionPt != null)
             {
                 Basic.CsysUtils.SetWcsOfCentePoint(temp);
             }
         }
         else if (block == rotation_x)
         {
             //---------Enter your code here-----------
             CsysUtils.RotateWcs(WCS.Axis.XAxis, 90);
         }
         else if (block == rotation_y)
         {
             //---------Enter your code here-----------
             CsysUtils.RotateWcs(WCS.Axis.YAxis, 90);
         }
         else if (block == rotation_z)
         {
             //---------Enter your code here-----------
             CsysUtils.RotateWcs(WCS.Axis.ZAxis, 90);
         }
     }
     catch (Exception ex)
     {
         //---- Enter your exception handling code here -----
         theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
     }
     return(0);
 }
        //------------------------------------------------------------------------------
        //Callback Name: update_cb
        //------------------------------------------------------------------------------
        public int update_cb(NXOpen.BlockStyler.UIBlock block)
        {
            try
            {
                if (block == selectionBody)
                {
                    //---------Enter your code here-----------

                    foreach (TaggedObject tobj in selectionBody.GetSelectedObjects())
                    {
                        if (tobj is DisplayableObject)
                        {
                            DisplayableObject disp = tobj as DisplayableObject;
                            disp.Highlight();
                        }
                        nxObjects.Add(tobj as NXObject);
                    }
                    this.moveObjectBasic = new MoveObjectBasic(nxObjects);
                    points = moveObjectBasic.CreatePoint();
                }
                else if (block == get_point)
                {
                    // ---------Enter your code here---------- -
                    Point3d temp = this.GetPoint();
                    if (this.selectionPt != null)
                    {
                        Basic.CsysUtils.SetWcsOfCentePoint(temp);
                    }
                }
                else if (block == rotation_x)
                {
                    //---------Enter your code here-----------
                    CsysUtils.RotateWcs(WCS.Axis.XAxis, 90);
                }
                else if (block == rotation_y)
                {
                    //---------Enter your code here-----------
                    CsysUtils.RotateWcs(WCS.Axis.YAxis, 90);
                }
                else if (block == rotation_z)
                {
                    //---------Enter your code here-----------
                    CsysUtils.RotateWcs(WCS.Axis.ZAxis, 90);
                }
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(0);
        }
Beispiel #5
0
 private void OK_Click(object sender, EventArgs e)
 {
     try
     {
         for (int i = 0; i < panel.Rows.Count; i++)
         {
             DisplayableObject singleObj = (DisplayableObject)NXObjectManager.Get((Tag)panel.GetCell(i, 0).Tag);
             singleObj.SetAttribute("CustomerBalloon", panel.GetCell(i, 1).Value.ToString());
         }
         MessageBox.Show("設定完成!");
     }
     catch (System.Exception ex)
     {
     }
 }
        /// <summary>
        /// 更改对象颜色
        /// </summary>
        /// <param name="displayableObject"></param>
        /// <param name="color"></param>
        public static void SetColor(this DisplayableObject displayableObject, int color)
        {
            NXOpen.Part displayPart = TheSession.Parts.Display;

            NXOpen.DisplayModification displayModification = TheSession.DisplayManager.NewDisplayModification();

            displayModification.ApplyToAllFaces = true;

            displayModification.ApplyToOwningParts = false;

            displayModification.NewColor = color;

            displayModification.Apply(new DisplayableObject[] { displayableObject });

            displayModification.Dispose();
        }
Beispiel #7
0
        /// <summary>
        /// Write a character on the console
        /// </summary>
        /// <param name="posX">The horizontal position on the console</param>
        /// <param name="posY">The vertical position on the console</param>
        /// <param name="asciiChar">An ASCII character</param>
        public static void FastDraw(int posX, int posY, DisplayableObject displayableObject)
        {
            lock (ConsoleWriterLock)
            {
                // Save console's cursor position
                CursorPosition cursorPos = ConsoleUtils.SnapCursorPosition();

                // Draw the character
                Console.ForegroundColor = displayableObject.Color;
                Console.SetCursorPosition(posX, posY);
                Console.Write(displayableObject);

                // reset the console cursor at his position
                ConsoleUtils.ResetCursorPosition(cursorPos);
            }
        }
Beispiel #8
0
        private void SGC_CellClick(object sender, GridCellClickEventArgs e)
        {
            #region 尺寸高亮
            if (e.GridCell.GridColumn.Name == "尺寸位置")
            {
                if (exOnj != null)
                {
                    exOnj.Unhighlight();
                }

                ((NXOpen.Drawings.DrawingSheet)workPart.DrawingSheets.FindObject(e.GridCell.Value.ToString())).Open();
                ((DisplayableObject)e.GridCell.GridRow.Cells["Dimension"].Value).Highlight();
                exOnj = ((DisplayableObject)e.GridCell.GridRow.Cells["Dimension"].Value);
                workPart.Views.Refresh();
            }
            #endregion
        }
Beispiel #9
0
        private void SGC_Panel_CellClick(object sender, GridCellClickEventArgs e)
        {
            try
            {
                if (CurrentRowIndex != -1)
                {
                    DisplayableObject unhighlight = (DisplayableObject)NXObjectManager.Get((Tag)panel.GetCell(CurrentRowIndex, 0).Tag);
                    unhighlight.Unhighlight();
                }

                CurrentRowIndex = e.GridCell.GridRow.Index;

                DisplayableObject highlight = (DisplayableObject)NXObjectManager.Get((Tag)panel.GetCell(CurrentRowIndex, 0).Tag);
                highlight.Highlight();

                workPart.Views.Refresh();
            }
            catch (System.Exception ex)
            {
            }
        }
Beispiel #10
0
    // Invoked when the SetColor button is clicked
    private void SetColorClicked(object sender, System.EventArgs e)
    {
        if (selectedComponent != null)
        {
            // Get the color ID from the colorTable, using the currently selected name
            // as the key. The find the corresponding color index in the displayed part

            UFDisp.ColorName colorID = (UFDisp.ColorName)colorTable[colorBox.SelectedItem];
            int colorIndex;
            theUFSession.Disp.AskClosestColorInDisplayedPart(colorID, out colorIndex);
            // Set an undo mark before modifying the color;

            theSession.SetUndoMark(Session.MarkVisibility.Visible, "Set color " + colorBox.SelectedItem);

            // Create a DisplayModification object to set the color

            DisplayModification displayMod = theSession.DisplayManager.NewDisplayModification();
            displayMod.ApplyToAllFaces = false;
            displayMod.NewColor        = colorIndex;
            DisplayableObject[] objArray = new DisplayableObject[1];
            objArray[0] = selectedComponent;
            displayMod.Apply(objArray);
        }
    }
        /// <summary>
        /// 测量两个对象之间的投影距离
        /// </summary>
        /// <param name="measureManager"></param>
        /// <param name="object1">对象1</param>
        /// <param name="object2">对象2</param>
        /// <param name="projectVector">投影矢量</param>
        /// <param name="type">测量类型</param>
        /// <returns>投影距离值</returns>
        public static double MeasureProjectDistance(this MeasureManager measureManager, DisplayableObject object1, DisplayableObject object2, Vector3d projectVector, MeasureManager.ProjectionType type)
        {
            NXOpen.Unit lengthUnit = WorkPart.UnitCollection.FindObject("MilliMeter");

            Direction direction1 = WorkPart.Directions.CreateDirection(new Point3d(), projectVector, NXOpen.SmartObject.UpdateOption.WithinModeling);

            var projectDistance = measureManager.NewDistance(lengthUnit, object1, object2, direction1, type);

            return(projectDistance.Value);
        }
        /// <summary>
        /// 显示对象,将对象所在图层设为可选图层
        /// </summary>
        /// <param name="objectToShow">要显示的对象</param>
        public static void Show(this DisplayableObject objectToShow)
        {
            TheSession.DisplayManager.ShowObjects(new DisplayableObject[] { objectToShow }, DisplayManager.LayerSetting.ChangeLayerToSelectable);

            WorkPart.ModelingViews.WorkView.FitAfterShowOrHide(View.ShowOrHideType.ShowOnly);
        }
Beispiel #13
0
        /// <summary>
        /// 設定標註尺寸顏色
        /// </summary>
        /// <param name="nNXObject"></param>
        /// <param name="color"></param>
        /// <returns></returns>
        public static bool SetDimensionColor(NXObject nNXObject, int color)
        {
            try
            {
                DisplayModification displayModification1;
                displayModification1 = theSession.DisplayManager.NewDisplayModification();
                displayModification1.ApplyToAllFaces    = false;
                displayModification1.ApplyToOwningParts = false;
                displayModification1.NewColor           = color;
                DisplayableObject[] objects1 = new DisplayableObject[1];

                string DimenType = nNXObject.GetType().ToString();
                if (DimenType == "NXOpen.Annotations.VerticalDimension")
                {
                    NXOpen.Annotations.VerticalDimension dimension = (NXOpen.Annotations.VerticalDimension)nNXObject;
                    objects1[0] = dimension;
                    displayModification1.Apply(objects1);
                }
                else if (DimenType == "NXOpen.Annotations.PerpendicularDimension")
                {
                    NXOpen.Annotations.PerpendicularDimension dimension = (NXOpen.Annotations.PerpendicularDimension)nNXObject;
                    objects1[0] = dimension;
                    displayModification1.Apply(objects1);
                }
                else if (DimenType == "NXOpen.Annotations.MinorAngularDimension")
                {
                    NXOpen.Annotations.MinorAngularDimension dimension = (NXOpen.Annotations.MinorAngularDimension)nNXObject;
                    objects1[0] = dimension;
                    displayModification1.Apply(objects1);
                }
                else if (DimenType == "NXOpen.Annotations.ChamferDimension")
                {
                    NXOpen.Annotations.ChamferDimension dimension = (NXOpen.Annotations.ChamferDimension)nNXObject;
                    objects1[0] = dimension;
                    displayModification1.Apply(objects1);
                }
                else if (DimenType == "NXOpen.Annotations.HorizontalDimension")
                {
                    NXOpen.Annotations.HorizontalDimension dimension = (NXOpen.Annotations.HorizontalDimension)nNXObject;
                    objects1[0] = dimension;
                    displayModification1.Apply(objects1);
                }
                else if (DimenType == "NXOpen.Annotations.HoleDimension")
                {
                    NXOpen.Annotations.HoleDimension dimension = (NXOpen.Annotations.HoleDimension)nNXObject;
                    objects1[0] = dimension;
                    displayModification1.Apply(objects1);
                }
                else if (DimenType == "NXOpen.Annotations.DiameterDimension")
                {
                    NXOpen.Annotations.DiameterDimension dimension = (NXOpen.Annotations.DiameterDimension)nNXObject;
                    objects1[0] = dimension;
                    displayModification1.Apply(objects1);
                }
                else if (DimenType == "NXOpen.Annotations.CylindricalDimension")
                {
                    NXOpen.Annotations.CylindricalDimension dimension = (NXOpen.Annotations.CylindricalDimension)nNXObject;
                    objects1[0] = dimension;
                    displayModification1.Apply(objects1);
                }
                else if (DimenType == "NXOpen.Annotations.RadiusDimension")
                {
                    NXOpen.Annotations.RadiusDimension dimension = (NXOpen.Annotations.RadiusDimension)nNXObject;
                    objects1[0] = dimension;
                    displayModification1.Apply(objects1);
                }
                else if (DimenType == "NXOpen.Annotations.ArcLengthDimension")
                {
                    NXOpen.Annotations.ArcLengthDimension dimension = (NXOpen.Annotations.ArcLengthDimension)nNXObject;
                    objects1[0] = dimension;
                    displayModification1.Apply(objects1);
                }
                else if (DimenType == "NXOpen.Annotations.AngularDimension")
                {
                    NXOpen.Annotations.AngularDimension dimension = (NXOpen.Annotations.AngularDimension)nNXObject;
                    objects1[0] = dimension;
                    displayModification1.Apply(objects1);
                }
                else if (DimenType == "NXOpen.Annotations.ParallelDimension")
                {
                    NXOpen.Annotations.ParallelDimension dimension = (NXOpen.Annotations.ParallelDimension)nNXObject;
                    objects1[0] = dimension;
                    displayModification1.Apply(objects1);
                }
            }
            catch (System.Exception ex)
            {
                return(false);
            }
            return(true);
        }
Beispiel #14
0
    //------------------------------------------------------------------------------
    //Callback Name: apply_cb
    //------------------------------------------------------------------------------
    public int apply_cb()
    {
        int errorCode = 0;

        NXOpen.Features.BlockFeatureBuilder blockFeatureBuilder1 = null;

        try
        {
            Part workPart = theSession.Parts.Work;

            //Get the values from UI Blocks
            PropertyList blockHeightProps = blockHeight.GetProperties();
            double       theHeight        = blockHeightProps.GetDouble("Value");
            blockHeightProps.Dispose();
            blockHeightProps = null;

            PropertyList blockWidthProps = blockWidth.GetProperties();
            double       theWidth        = blockWidthProps.GetDouble("Value");
            blockWidthProps.Dispose();
            blockWidthProps = null;

            PropertyList blockLengthProps = blockLength.GetProperties();
            double       theLength        = blockLengthProps.GetDouble("Value");
            blockLengthProps.Dispose();
            blockLengthProps = null;

            PropertyList blockOriginProps = blockOrigin.GetProperties();
            Point3d      originPoint      = blockOriginProps.GetPoint("Point");
            blockOriginProps.Dispose();
            blockOriginProps = null;

            PropertyList blockColorProps = blockColor.GetProperties();
            int[]        color           = blockColorProps.GetIntegerVector("Value");
            blockColorProps.Dispose();
            blockColorProps = null;

            //Create the NX block
            NXOpen.Features.Feature nullFeatures_Feature = null;
            blockFeatureBuilder1 = workPart.Features.CreateBlockFeatureBuilder(nullFeatures_Feature);

            blockFeatureBuilder1.SetOriginAndLengths(originPoint, theLength.ToString(), theHeight.ToString(), theWidth.ToString());

            NXOpen.Features.Feature feature1;
            feature1 = blockFeatureBuilder1.CommitFeature();


            // Get the body from Feature
            NXOpen.Features.BodyFeature bodyFeat = (NXOpen.Features.BodyFeature)feature1;
            Body[] bodies = new Body[1];
            bodies = bodyFeat.GetBodies();
            // Apply the color to feature body
            DisplayModification displayModification1 = theSession.DisplayManager.NewDisplayModification();
            displayModification1.ApplyToAllFaces = true;
            displayModification1.NewColor        = color[0];
            DisplayableObject[] objects1 = new DisplayableObject[1];
            objects1[0] = bodies[0];
            displayModification1.Apply(objects1);
            displayModification1.Dispose();
        }
        catch (Exception ex)
        {
            //---- Enter your exception handling code here -----
            errorCode = 1;
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.Message);
        }
        finally
        {
            if (blockFeatureBuilder1 != null)
            {
                blockFeatureBuilder1.Destroy();
                blockFeatureBuilder1 = null;
            }
        }
        return(errorCode);
    }
Beispiel #15
0
 public static double MeasureDistance(this MeasureManager measureManager, DisplayableObject object1, DisplayableObject object2, Vector3d projectVector, MeasureManager.ProjectionType type) => measureManager.MeasureProjectDistance(object1, object2, projectVector, type);
 /// <summary>
 /// 设置对象的透明度
 /// </summary>
 /// <param name="displayableObject">要设置透明度的对象</param>
 /// <param name="translucency">透明度值</param>
 /// <param name="applyToAllFaces">是否应用于所有面</param>
 /// <param name="applyToOwningParts">是否应用于所属部件</param>
 public static void SetTranslucency(this DisplayableObject displayableObject, int translucency, bool applyToAllFaces = true, bool applyToOwningParts = false) => SetTranslucency(new DisplayableObject[] { displayableObject }, translucency, applyToAllFaces, applyToOwningParts);
Beispiel #17
0
 /// <summary>
 /// 测量点到对象之间的投影距离
 /// </summary>
 /// <param name="point"></param>
 /// <param name="object">对象2</param>
 /// <param name="projectVector">投影矢量</param>
 /// <param name="type">测量类型</param>
 /// <returns>投影距离值</returns>
 public static double DistanceTo(this Point3d point, DisplayableObject @object, Vector3d projectVector, MeasureManager.ProjectionType type) => WorkPart.MeasureManager.MeasureProjectDistance(point, @object, projectVector, type);
Beispiel #18
0
 public static double MeasureDistance(this MeasureManager theMeasureManager, Point3d point, DisplayableObject @object, Vector3d projectVector, MeasureManager.ProjectionType type) => theMeasureManager.MeasureProjectDistance(point, @object, projectVector, type);
Beispiel #19
0
    public void function(string ToleranceValue, string PrimaryDatumReference, string SecondaryDatumReference, string TertiaryDatumReference, object ZoneShape,object Characteristic, object MaterialModifier, object PrimaryMaterialCondition, object SecondaryMaterialCondition, object TertiaryMaterialCondition,
            object frameStyle, double Annotationletter, double duanxian, Point3d point1, DisplayableObject point2, DisplayableObject guanlian, object LeaderType)
    {
        NXOpen.Annotations.Fcf nullAnnotations_Fcf = null;
            NXOpen.Annotations.PmiFeatureControlFrameBuilder pmiFeatureControlFrameBuilder1;
            pmiFeatureControlFrameBuilder1 = workPart.Annotations.CreatePmiFeatureControlFrameBuilder(nullAnnotations_Fcf);

            pmiFeatureControlFrameBuilder1.Origin.SetInferRelativeToGeometry(true);

            pmiFeatureControlFrameBuilder1.Origin.Anchor = NXOpen.Annotations.OriginBuilder.AlignmentPosition.MidCenter;

            pmiFeatureControlFrameBuilder1.Characteristic = (NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic)Characteristic;

            pmiFeatureControlFrameBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.ModelView;

            pmiFeatureControlFrameBuilder1.Origin.SetInferRelativeToGeometry(true);

            NXOpen.Annotations.LeaderData leaderData1;
            leaderData1 = workPart.Annotations.CreateLeaderData();

            leaderData1.Arrowhead = NXOpen.Annotations.LeaderData.ArrowheadType.FilledArrow;

            pmiFeatureControlFrameBuilder1.Leader.Leaders.Append(leaderData1);

            leaderData1.Perpendicular = false;

            leaderData1.StubSize = duanxian;

            leaderData1.StubSide = NXOpen.Annotations.LeaderSide.Inferred;

            TaggedObject taggedObject1;
            taggedObject1 = pmiFeatureControlFrameBuilder1.FeatureControlFrameDataList.FindItem(0);

            NXOpen.Annotations.FeatureControlFrameDataBuilder featureControlFrameDataBuilder1 = (NXOpen.Annotations.FeatureControlFrameDataBuilder)taggedObject1;

            featureControlFrameDataBuilder1.ZoneShape = (NXOpen.Annotations.FeatureControlFrameDataBuilder.ToleranceZoneShape)ZoneShape;

            featureControlFrameDataBuilder1.ToleranceValue = ToleranceValue;

            featureControlFrameDataBuilder1.MaterialModifier = (NXOpen.Annotations.FeatureControlFrameDataBuilder.ToleranceMaterialModifier)MaterialModifier;
            featureControlFrameDataBuilder1.PrimaryDatumReference.Letter = PrimaryDatumReference;//基准
            featureControlFrameDataBuilder1.SecondaryDatumReference.Letter = SecondaryDatumReference;
            featureControlFrameDataBuilder1.TertiaryDatumReference.Letter = TertiaryDatumReference;
            if (PrimaryMaterialCondition != null)
            {

                featureControlFrameDataBuilder1.PrimaryDatumReference.MaterialCondition = (NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition)PrimaryMaterialCondition;//材料按顺序为L M 不填 S

            }

            if (SecondaryMaterialCondition != null)
            {
                featureControlFrameDataBuilder1.SecondaryDatumReference.MaterialCondition = (NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition)SecondaryMaterialCondition;
            }

            if (TertiaryMaterialCondition != null)
            {
                featureControlFrameDataBuilder1.TertiaryDatumReference.MaterialCondition = (NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition)TertiaryMaterialCondition;
            }

            pmiFeatureControlFrameBuilder1.Origin.SetInferRelativeToGeometry(true);

            NXOpen.Annotations.Annotation.AssociativeOriginData assocOrigin1;
            assocOrigin1.OriginType = NXOpen.Annotations.AssociativeOriginType.Drag;
            NXOpen.View nullView = null;
            assocOrigin1.View = nullView;
            assocOrigin1.ViewOfGeometry = nullView;
            NXOpen.Point nullPoint = null;
            assocOrigin1.PointOnGeometry = nullPoint;

            assocOrigin1.VertAnnotation = null;
            assocOrigin1.VertAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft;
            assocOrigin1.HorizAnnotation = null;
            assocOrigin1.HorizAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft;
            assocOrigin1.AlignedAnnotation = null;
            assocOrigin1.DimensionLine = 0;
            assocOrigin1.AssociatedView = nullView;
            assocOrigin1.AssociatedPoint = nullPoint;
            assocOrigin1.OffsetAnnotation = null;
            assocOrigin1.OffsetAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft;
            assocOrigin1.XOffsetFactor = 0.0;
            assocOrigin1.YOffsetFactor = 0.0;
            assocOrigin1.StackAlignmentPosition = NXOpen.Annotations.StackAlignmentPosition.Above;
            pmiFeatureControlFrameBuilder1.Origin.SetAssociativeOrigin(assocOrigin1);

            pmiFeatureControlFrameBuilder1.FrameStyle = (NXOpen.Annotations.FeatureControlFrameBuilder.FcfFrameStyle)frameStyle;//单框复合框

            if (guanlian != null)
            {
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanlian);

            }
            //NXOpen.Point point4;
            //point4 = workPart.Points.CreatePoint(point1);
            pmiFeatureControlFrameBuilder1.Origin.Origin.SetValue(null, nullView, point1);

            point2.Highlight();
            try
            {
            //    if (LeaderType.Equals(NXOpen.Annotations.LeaderData.LeaderType.Plain))
            //    {
                    leaderData1.TerminatorType = (NXOpen.Annotations.LeaderData.LeaderType)LeaderType;
                    NXOpen.Point point3 = (Point)point2;
                    // point3 = workPart.Points.CreatePoint(point2);

                    Point3d p = point3.Coordinates;
                    leaderData1.Leader.SetValue(point2, workPart.ModelingViews.WorkView, p);//折线
               // }
            }
            catch (Exception ex)
            { UI.GetUI().NXMessageBox.Show("error", NXMessageBox.DialogType.Error, ex.ToString()); }
            //else
            //{
            //    leaderData1.TerminatorType =(NXOpen.Annotations.LeaderData.LeaderType)LeaderType;//标志
            //    NXOpen.Edge point3 = (Edge)point2;
            //    double[] p1=new double[3];
            //    double[] p2=new double[3];
            //    int v;
            //    theUfSession.Modl.AskEdgeVerts(point3.Tag,p1,p2,out v);
            //    double[] p3 = new double[3];
            //    p3[0] = (p1[0] + p2[0]) / 2;
            //    p3[1] = (p1[1] + p2[1]) / 2;
            //    p3[2] = (p1[2] + p2[2]) / 2;
            //    Point3d pp = new Point3d(p3[0], p3[0], p3[0]);
            //    // //Point3d p = point3.Coordinates;
            //   leaderData1.Leader.SetValue(point2, workPart.ModelingViews.WorkView, pp);//折线
            //}
            // NXOpen.Features.Extrude extrude1 = (NXOpen.Features.Extrude)workPart.Features.FindObject("EXTRUDE(3)");
            // Edge edge1 = (Edge)extrude1.FindObject("EDGE * 180 * 190 {(3,10,5)(3,10,0)(3,10,-5) EXTRUDE(2)}");
            // Point3d point2 = new Point3d(3.0, 10.0, 3.02209729734126);
            // leaderData1.Leader.SetValue(edge1, workPart.ModelingViews.WorkView, point1);

            // leaderData1.Arrowhead = NXOpen.Annotations.LeaderData.ArrowheadType.None;

            //// NXOpen.View nullView = null;
            // Point3d point3= new Point3d(3.0, 10.0, 5.0);
            // leaderData1.Leader.SetValue(edge1, workPart.ModelingViews.WorkView, point2);

            NXObject nXObject1;
            nXObject1 = pmiFeatureControlFrameBuilder1.Commit();

            //样式设置
            NXOpen.Annotations.Fcf fcf1 = (NXOpen.Annotations.Fcf)nXObject1;

            NXOpen.Annotations.SymbolPreferences symbolPreferences1;
            symbolPreferences1 = fcf1.GetSymbolPreferences();

            NXOpen.Annotations.LineAndArrowPreferences lineAndArrowPreferences1;
            lineAndArrowPreferences1 = fcf1.GetLineAndArrowPreferences();

            NXOpen.Annotations.LetteringPreferences letteringPreferences1;
            letteringPreferences1 = fcf1.GetLetteringPreferences();
            lineAndArrowPreferences1.LeaderLocation = NXOpen.Annotations.VerticalTextJustification.Middle;

            fcf1.SetLineAndArrowPreferences(lineAndArrowPreferences1);
            NXOpen.Annotations.Lettering generalText1;
            generalText1.Size = Annotationletter;//文本设置值
            generalText1.CharacterSpaceFactor = 0.5;
            generalText1.AspectRatio = 0.57;
            generalText1.LineSpaceFactor = 1.0;
            generalText1.Cfw.Color = 211;
            generalText1.Cfw.Font = 2;
            generalText1.Cfw.Width = NXOpen.Annotations.LineWidth.Thin;
            letteringPreferences1.SetGeneralText(generalText1);
            fcf1.LeaderOrientation = NXOpen.Annotations.LeaderOrientation.FromRight;
            //fcf1.LeaderOrientation = NXOpen.Annotations.LeaderOrientation.FromLeft;
            fcf1.SetLetteringPreferences(letteringPreferences1);

            pmiFeatureControlFrameBuilder1.Destroy();
    }
Beispiel #20
0
    public void function(string ToleranceValue, string PrimaryDatumReference, string SecondaryDatumReference, string TertiaryDatumReference, object ZoneShape, object Characteristic, object MaterialModifier, object PrimaryMaterialCondition, object SecondaryMaterialCondition, object TertiaryMaterialCondition,
                         object frameStyle, double Annotationletter, double duanxian, Point3d point1, DisplayableObject point2, DisplayableObject guanlian, object LeaderType)
    {
        NXOpen.Annotations.Fcf nullAnnotations_Fcf = null;
        NXOpen.Annotations.PmiFeatureControlFrameBuilder pmiFeatureControlFrameBuilder1;
        pmiFeatureControlFrameBuilder1 = workPart.Annotations.CreatePmiFeatureControlFrameBuilder(nullAnnotations_Fcf);

        pmiFeatureControlFrameBuilder1.Origin.SetInferRelativeToGeometry(true);

        pmiFeatureControlFrameBuilder1.Origin.Anchor = NXOpen.Annotations.OriginBuilder.AlignmentPosition.MidCenter;

        pmiFeatureControlFrameBuilder1.Characteristic = (NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic)Characteristic;


        pmiFeatureControlFrameBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.ModelView;

        pmiFeatureControlFrameBuilder1.Origin.SetInferRelativeToGeometry(true);

        NXOpen.Annotations.LeaderData leaderData1;
        leaderData1 = workPart.Annotations.CreateLeaderData();

        leaderData1.Arrowhead = NXOpen.Annotations.LeaderData.ArrowheadType.FilledArrow;

        pmiFeatureControlFrameBuilder1.Leader.Leaders.Append(leaderData1);

        leaderData1.Perpendicular = false;

        leaderData1.StubSize = duanxian;

        leaderData1.StubSide = NXOpen.Annotations.LeaderSide.Inferred;

        TaggedObject taggedObject1;

        taggedObject1 = pmiFeatureControlFrameBuilder1.FeatureControlFrameDataList.FindItem(0);

        NXOpen.Annotations.FeatureControlFrameDataBuilder featureControlFrameDataBuilder1 = (NXOpen.Annotations.FeatureControlFrameDataBuilder)taggedObject1;

        featureControlFrameDataBuilder1.ZoneShape = (NXOpen.Annotations.FeatureControlFrameDataBuilder.ToleranceZoneShape)ZoneShape;

        featureControlFrameDataBuilder1.ToleranceValue = ToleranceValue;

        featureControlFrameDataBuilder1.MaterialModifier               = (NXOpen.Annotations.FeatureControlFrameDataBuilder.ToleranceMaterialModifier)MaterialModifier;
        featureControlFrameDataBuilder1.PrimaryDatumReference.Letter   = PrimaryDatumReference;  //基准
        featureControlFrameDataBuilder1.SecondaryDatumReference.Letter = SecondaryDatumReference;
        featureControlFrameDataBuilder1.TertiaryDatumReference.Letter  = TertiaryDatumReference;
        if (PrimaryMaterialCondition != null)
        {
            featureControlFrameDataBuilder1.PrimaryDatumReference.MaterialCondition = (NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition)PrimaryMaterialCondition;    //材料按顺序为L M 不填 S
        }

        if (SecondaryMaterialCondition != null)
        {
            featureControlFrameDataBuilder1.SecondaryDatumReference.MaterialCondition = (NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition)SecondaryMaterialCondition;
        }

        if (TertiaryMaterialCondition != null)
        {
            featureControlFrameDataBuilder1.TertiaryDatumReference.MaterialCondition = (NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition)TertiaryMaterialCondition;
        }

        pmiFeatureControlFrameBuilder1.Origin.SetInferRelativeToGeometry(true);

        NXOpen.Annotations.Annotation.AssociativeOriginData assocOrigin1;
        assocOrigin1.OriginType = NXOpen.Annotations.AssociativeOriginType.Drag;
        NXOpen.View nullView = null;
        assocOrigin1.View           = nullView;
        assocOrigin1.ViewOfGeometry = nullView;
        NXOpen.Point nullPoint = null;
        assocOrigin1.PointOnGeometry = nullPoint;

        assocOrigin1.VertAnnotation          = null;
        assocOrigin1.VertAlignmentPosition   = NXOpen.Annotations.AlignmentPosition.TopLeft;
        assocOrigin1.HorizAnnotation         = null;
        assocOrigin1.HorizAlignmentPosition  = NXOpen.Annotations.AlignmentPosition.TopLeft;
        assocOrigin1.AlignedAnnotation       = null;
        assocOrigin1.DimensionLine           = 0;
        assocOrigin1.AssociatedView          = nullView;
        assocOrigin1.AssociatedPoint         = nullPoint;
        assocOrigin1.OffsetAnnotation        = null;
        assocOrigin1.OffsetAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft;
        assocOrigin1.XOffsetFactor           = 0.0;
        assocOrigin1.YOffsetFactor           = 0.0;
        assocOrigin1.StackAlignmentPosition  = NXOpen.Annotations.StackAlignmentPosition.Above;
        pmiFeatureControlFrameBuilder1.Origin.SetAssociativeOrigin(assocOrigin1);

        pmiFeatureControlFrameBuilder1.FrameStyle = (NXOpen.Annotations.FeatureControlFrameBuilder.FcfFrameStyle)frameStyle;    //单框复合框

        if (guanlian != null)
        {
            bool added1;
            added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanlian);
        }
        //NXOpen.Point point4;
        //point4 = workPart.Points.CreatePoint(point1);
        pmiFeatureControlFrameBuilder1.Origin.Origin.SetValue(null, nullView, point1);

        point2.Highlight();
        try
        {
            //    if (LeaderType.Equals(NXOpen.Annotations.LeaderData.LeaderType.Plain))
            //    {
            leaderData1.TerminatorType = (NXOpen.Annotations.LeaderData.LeaderType)LeaderType;
            NXOpen.Point point3 = (Point)point2;
            // point3 = workPart.Points.CreatePoint(point2);

            Point3d p = point3.Coordinates;
            leaderData1.Leader.SetValue(point2, workPart.ModelingViews.WorkView, p);        //折线
            // }
        }
        catch (Exception ex)
        { UI.GetUI().NXMessageBox.Show("error", NXMessageBox.DialogType.Error, ex.ToString()); }
        //else
        //{
        //    leaderData1.TerminatorType =(NXOpen.Annotations.LeaderData.LeaderType)LeaderType;//标志
        //    NXOpen.Edge point3 = (Edge)point2;
        //    double[] p1=new double[3];
        //    double[] p2=new double[3];
        //    int v;
        //    theUfSession.Modl.AskEdgeVerts(point3.Tag,p1,p2,out v);
        //    double[] p3 = new double[3];
        //    p3[0] = (p1[0] + p2[0]) / 2;
        //    p3[1] = (p1[1] + p2[1]) / 2;
        //    p3[2] = (p1[2] + p2[2]) / 2;
        //    Point3d pp = new Point3d(p3[0], p3[0], p3[0]);
        //    // //Point3d p = point3.Coordinates;
        //   leaderData1.Leader.SetValue(point2, workPart.ModelingViews.WorkView, pp);//折线
        //}
        // NXOpen.Features.Extrude extrude1 = (NXOpen.Features.Extrude)workPart.Features.FindObject("EXTRUDE(3)");
        // Edge edge1 = (Edge)extrude1.FindObject("EDGE * 180 * 190 {(3,10,5)(3,10,0)(3,10,-5) EXTRUDE(2)}");
        // Point3d point2 = new Point3d(3.0, 10.0, 3.02209729734126);
        // leaderData1.Leader.SetValue(edge1, workPart.ModelingViews.WorkView, point1);

        // leaderData1.Arrowhead = NXOpen.Annotations.LeaderData.ArrowheadType.None;

        //// NXOpen.View nullView = null;
        // Point3d point3= new Point3d(3.0, 10.0, 5.0);
        // leaderData1.Leader.SetValue(edge1, workPart.ModelingViews.WorkView, point2);


        NXObject nXObject1;

        nXObject1 = pmiFeatureControlFrameBuilder1.Commit();


        //样式设置
        NXOpen.Annotations.Fcf fcf1 = (NXOpen.Annotations.Fcf)nXObject1;

        NXOpen.Annotations.SymbolPreferences symbolPreferences1;
        symbolPreferences1 = fcf1.GetSymbolPreferences();

        NXOpen.Annotations.LineAndArrowPreferences lineAndArrowPreferences1;
        lineAndArrowPreferences1 = fcf1.GetLineAndArrowPreferences();

        NXOpen.Annotations.LetteringPreferences letteringPreferences1;
        letteringPreferences1 = fcf1.GetLetteringPreferences();
        lineAndArrowPreferences1.LeaderLocation = NXOpen.Annotations.VerticalTextJustification.Middle;

        fcf1.SetLineAndArrowPreferences(lineAndArrowPreferences1);
        NXOpen.Annotations.Lettering generalText1;
        generalText1.Size = Annotationletter;    //文本设置值
        generalText1.CharacterSpaceFactor = 0.5;
        generalText1.AspectRatio          = 0.57;
        generalText1.LineSpaceFactor      = 1.0;
        generalText1.Cfw.Color            = 211;
        generalText1.Cfw.Font             = 2;
        generalText1.Cfw.Width            = NXOpen.Annotations.LineWidth.Thin;
        letteringPreferences1.SetGeneralText(generalText1);
        fcf1.LeaderOrientation = NXOpen.Annotations.LeaderOrientation.FromRight;
        //fcf1.LeaderOrientation = NXOpen.Annotations.LeaderOrientation.FromLeft;
        fcf1.SetLetteringPreferences(letteringPreferences1);

        pmiFeatureControlFrameBuilder1.Destroy();
    }
Beispiel #21
0
        /// <summary>
        /// 使用 NXOpen 测量两个对象之间的距离
        /// </summary>
        /// <param name="measureManager"></param>
        /// <param name="object1">对象1</param>
        /// <param name="object2">对象2</param>
        /// <returns>距离值</returns>
        public static (bool Success, double Distance, Point3d PointOn1stObject, Point3d PointOn2ndObject) MeasureDistance(this MeasureManager measureManager, DisplayableObject object1, DisplayableObject object2)
        {
            try
            {
                NXOpen.Unit lengthUnit = WorkPart.UnitCollection.FindObject("MilliMeter");

                MeasureDistance distance = measureManager.NewDistance(lengthUnit, MeasureManager.MeasureType.Minimum, true, object1, object2);

                var measureFeature = distance.CreateFeature();

                var measureLine = measureFeature.GetEntities()[0] as Line;

                var minimumDistance = measureLine.GetLength();

                Point3d pointOn1stObject = measureLine.StartPoint;

                Point3d pointOn2ndObject = measureLine.EndPoint;

                measureFeature.Delete();

                return(true, minimumDistance, pointOn1stObject, pointOn2ndObject);
            }
            catch (Exception)
            {
                return(false, 0, new Point3d(), new Point3d());
            }
        }
Beispiel #22
0
    public void function_note(string[] zhushiwenzi, DisplayableObject guanlian, NXObject zhiyinobj, Point3d placeptobj)
    {
        NXOpen.Annotations.SimpleDraftingAid nullAnnotations_SimpleDraftingAid = null;
        NXOpen.Annotations.PmiNoteBuilder    pmiNoteBuilder1;
        pmiNoteBuilder1 = workPart.Annotations.CreatePmiNoteBuilder(nullAnnotations_SimpleDraftingAid);

        pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);

        pmiNoteBuilder1.Origin.Anchor = NXOpen.Annotations.OriginBuilder.AlignmentPosition.MidCenter;

        pmiNoteBuilder1.TextAlignment = NXOpen.Annotations.DraftingNoteBuilder.TextAlign.Middle;

        pmiNoteBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.ModelView;

        pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);

        NXOpen.Annotations.LeaderData leaderData1;
        leaderData1 = workPart.Annotations.CreateLeaderData();

        leaderData1.Arrowhead = NXOpen.Annotations.LeaderData.ArrowheadType.FilledArrow;

        pmiNoteBuilder1.Leader.Leaders.Append(leaderData1);

        leaderData1.StubSide = NXOpen.Annotations.LeaderSide.Inferred;

        leaderData1.StubSize = 5.0;

        leaderData1.Perpendicular = false;

        //double symbolscale1;
        //symbolscale1 = pmiNoteBuilder1.Text.TextBlock.SymbolScale;

        //double symbolaspectratio1;
        //symbolaspectratio1 = pmiNoteBuilder1.Text.TextBlock.SymbolAspectRatio;

        Xform xform1;

        xform1 = workPart.Annotations.GetDefaultAnnotationPlane(NXOpen.Annotations.PmiDefaultPlane.ModelView);

        pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);

        //pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);

        pmiNoteBuilder1.Text.TextBlock.SetText(zhushiwenzi);

        //NXOpen.Annotations.Annotation.AssociativeOriginData assocOrigin1;
        //assocOrigin1.OriginType = NXOpen.Annotations.AssociativeOriginType.Drag;
        //NXOpen.View nullView = null;
        //assocOrigin1.View = nullView;
        //assocOrigin1.ViewOfGeometry = nullView;
        //NXOpen.Point nullPoint = null;
        //assocOrigin1.PointOnGeometry = nullPoint;
        //assocOrigin1.VertAnnotation = null;
        //assocOrigin1.VertAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft;
        //assocOrigin1.HorizAnnotation = null;
        //assocOrigin1.HorizAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft;
        //assocOrigin1.AlignedAnnotation = null;
        //assocOrigin1.DimensionLine = 0;
        //assocOrigin1.AssociatedView = nullView;
        //assocOrigin1.AssociatedPoint = nullPoint;
        //assocOrigin1.OffsetAnnotation = null;
        //assocOrigin1.OffsetAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft;
        //assocOrigin1.XOffsetFactor = 0.0;
        //assocOrigin1.YOffsetFactor = 0.0;
        //assocOrigin1.StackAlignmentPosition = NXOpen.Annotations.StackAlignmentPosition.Above;
        //pmiNoteBuilder1.Origin.SetAssociativeOrigin(assocOrigin1);

        bool added1;

        added1 = pmiNoteBuilder1.AssociatedObjects.Objects.Add(guanlian);


        pmiNoteBuilder1.Origin.Origin.SetValue(null, null, placeptobj);

        pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);
        if (zhiyinobj != null)
        {
            Point   zhiyin     = (Point)zhiyinobj;
            Point3d zhiyindian = zhiyin.Coordinates;
            //NXOpen.Features.Extrude extrude1 = (NXOpen.Features.Extrude)workPart.Features.FindObject("EXTRUDE(3)");
            //Edge edge1 = (Edge)extrude1.FindObject("EDGE * 120 * 140 {(11,2,-5)(11,0.5,-5)(11,-1,-5) EXTRUDE(2)}");
            //edge1.GetVertices();
            leaderData1.Leader.SetValue(zhiyin, workPart.ModelingViews.WorkView, zhiyindian);
        }
        NXObject nXObject1;

        nXObject1 = pmiNoteBuilder1.Commit();

        pmiNoteBuilder1.Destroy();
    }
        /// <summary>
        /// 测量两个对象之间的投影距离,返回距离以及点信息,只能是当前工作部件中的对象,可用类型为 Point, Curve, Edge, Face, Body, Datum Plane.
        /// </summary>
        /// <param name="measureManager"></param>
        /// <param name="object1">对象1</param>
        /// <param name="object2">对象2</param>
        /// <param name="projectVector">投影矢量</param>
        /// <param name="type">测量类型</param>
        /// <returns>投影距离值</returns>
        public static MeasureResult MeasureProjectDistanceWithDetail(this MeasureManager measureManager, DisplayableObject object1, DisplayableObject object2, Vector3d projectVector, MeasureManager.ProjectionType type)
        {
            var measure = MeasureProjectDistance(measureManager, new NXObject[] { object1 }, new NXObject[] { object2 }, projectVector, type);

            return(new MeasureResult(measure.Success, measure.Distance, measure.PointOn1stObjects, measure.PointOn2ndObjects));
        }
    public void function_note(string[] zhushiwenzi, DisplayableObject guanlian, NXObject zhiyinobj, Point3d placeptobj)
    {
        NXOpen.Annotations.SimpleDraftingAid nullAnnotations_SimpleDraftingAid = null;
            NXOpen.Annotations.PmiNoteBuilder pmiNoteBuilder1;
            pmiNoteBuilder1 = workPart.Annotations.CreatePmiNoteBuilder(nullAnnotations_SimpleDraftingAid);

            pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);

            pmiNoteBuilder1.Origin.Anchor = NXOpen.Annotations.OriginBuilder.AlignmentPosition.MidCenter;

            pmiNoteBuilder1.TextAlignment = NXOpen.Annotations.DraftingNoteBuilder.TextAlign.Middle;

            pmiNoteBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.ModelView;

            pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);

            NXOpen.Annotations.LeaderData leaderData1;
            leaderData1 = workPart.Annotations.CreateLeaderData();

            leaderData1.Arrowhead = NXOpen.Annotations.LeaderData.ArrowheadType.FilledArrow;

            pmiNoteBuilder1.Leader.Leaders.Append(leaderData1);

            leaderData1.StubSide = NXOpen.Annotations.LeaderSide.Inferred;

            leaderData1.StubSize = 5.0;

            leaderData1.Perpendicular = false;

            //double symbolscale1;
            //symbolscale1 = pmiNoteBuilder1.Text.TextBlock.SymbolScale;

            //double symbolaspectratio1;
            //symbolaspectratio1 = pmiNoteBuilder1.Text.TextBlock.SymbolAspectRatio;

            Xform xform1;
            xform1 = workPart.Annotations.GetDefaultAnnotationPlane(NXOpen.Annotations.PmiDefaultPlane.ModelView);

            pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);

            //pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);

            pmiNoteBuilder1.Text.TextBlock.SetText(zhushiwenzi);

            //NXOpen.Annotations.Annotation.AssociativeOriginData assocOrigin1;
            //assocOrigin1.OriginType = NXOpen.Annotations.AssociativeOriginType.Drag;
            //NXOpen.View nullView = null;
            //assocOrigin1.View = nullView;
            //assocOrigin1.ViewOfGeometry = nullView;
            //NXOpen.Point nullPoint = null;
            //assocOrigin1.PointOnGeometry = nullPoint;
            //assocOrigin1.VertAnnotation = null;
            //assocOrigin1.VertAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft;
            //assocOrigin1.HorizAnnotation = null;
            //assocOrigin1.HorizAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft;
            //assocOrigin1.AlignedAnnotation = null;
            //assocOrigin1.DimensionLine = 0;
            //assocOrigin1.AssociatedView = nullView;
            //assocOrigin1.AssociatedPoint = nullPoint;
            //assocOrigin1.OffsetAnnotation = null;
            //assocOrigin1.OffsetAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft;
            //assocOrigin1.XOffsetFactor = 0.0;
            //assocOrigin1.YOffsetFactor = 0.0;
            //assocOrigin1.StackAlignmentPosition = NXOpen.Annotations.StackAlignmentPosition.Above;
            //pmiNoteBuilder1.Origin.SetAssociativeOrigin(assocOrigin1);

            bool added1;
           added1 = pmiNoteBuilder1.AssociatedObjects.Objects.Add(guanlian);

                pmiNoteBuilder1.Origin.Origin.SetValue(null, null, placeptobj);

                pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);
                if (zhiyinobj != null)
                {
                    Point zhiyin = (Point)zhiyinobj;
                    Point3d zhiyindian = zhiyin.Coordinates;
                    //NXOpen.Features.Extrude extrude1 = (NXOpen.Features.Extrude)workPart.Features.FindObject("EXTRUDE(3)");
                    //Edge edge1 = (Edge)extrude1.FindObject("EDGE * 120 * 140 {(11,2,-5)(11,0.5,-5)(11,-1,-5) EXTRUDE(2)}");
                    //edge1.GetVertices();
                    leaderData1.Leader.SetValue(zhiyin, workPart.ModelingViews.WorkView, zhiyindian);
                }
                NXObject nXObject1;
                nXObject1 = pmiNoteBuilder1.Commit();

                pmiNoteBuilder1.Destroy();
    }
        /// <summary>
        /// 测量点到对象之间的投影距离
        /// </summary>
        /// <param name="measureManager"></param>
        /// <param name="point"></param>
        /// <param name="object">对象2</param>
        /// <param name="projectVector">投影矢量</param>
        /// <param name="type">测量类型</param>
        /// <returns>投影距离值</returns>
        public static double MeasureProjectDistance(this MeasureManager measureManager, Point3d point, DisplayableObject @object, Vector3d projectVector, MeasureManager.ProjectionType type)
        {
            var tempPt = WorkPart.Points.CreatePoint(point);

            double distance = measureManager.MeasureProjectDistance(tempPt, @object, projectVector, type);

            tempPt.Delete();

            return(distance);
        }