Beispiel #1
0
        /// <summary>
        /// 回傳標註尺寸的顏色
        /// </summary>
        /// <param name="nNXObject"></param>
        /// <returns></returns>
        public static int GetDimensionColor(NXObject nNXObject)
        {
            int oldColor = -1;

            try
            {
                string DimenType = nNXObject.GetType().ToString();
                if (DimenType == "NXOpen.Annotations.VerticalDimension")
                {
                    NXOpen.Annotations.VerticalDimension dimension = (NXOpen.Annotations.VerticalDimension)nNXObject;
                    return(oldColor = dimension.Color);
                }
                else if (DimenType == "NXOpen.Annotations.PerpendicularDimension")
                {
                    NXOpen.Annotations.PerpendicularDimension dimension = (NXOpen.Annotations.PerpendicularDimension)nNXObject;
                    return(oldColor = dimension.Color);
                }
                else if (DimenType == "NXOpen.Annotations.MinorAngularDimension")
                {
                    NXOpen.Annotations.MinorAngularDimension dimension = (NXOpen.Annotations.MinorAngularDimension)nNXObject;
                    return(oldColor = dimension.Color);
                }
                else if (DimenType == "NXOpen.Annotations.ChamferDimension")
                {
                    NXOpen.Annotations.ChamferDimension dimension = (NXOpen.Annotations.ChamferDimension)nNXObject;
                    return(oldColor = dimension.Color);
                }
                else if (DimenType == "NXOpen.Annotations.HorizontalDimension")
                {
                    NXOpen.Annotations.HorizontalDimension dimension = (NXOpen.Annotations.HorizontalDimension)nNXObject;
                    return(oldColor = dimension.Color);
                }
                else if (DimenType == "NXOpen.Annotations.HoleDimension")
                {
                    NXOpen.Annotations.HoleDimension dimension = (NXOpen.Annotations.HoleDimension)nNXObject;
                    return(oldColor = dimension.Color);
                }
                else if (DimenType == "NXOpen.Annotations.DiameterDimension")
                {
                    NXOpen.Annotations.DiameterDimension dimension = (NXOpen.Annotations.DiameterDimension)nNXObject;
                    return(oldColor = dimension.Color);
                }
                else if (DimenType == "NXOpen.Annotations.CylindricalDimension")
                {
                    NXOpen.Annotations.CylindricalDimension dimension = (NXOpen.Annotations.CylindricalDimension)nNXObject;
                    return(oldColor = dimension.Color);
                }
                else if (DimenType == "NXOpen.Annotations.RadiusDimension")
                {
                    NXOpen.Annotations.RadiusDimension dimension = (NXOpen.Annotations.RadiusDimension)nNXObject;
                    return(oldColor = dimension.Color);
                }
                else if (DimenType == "NXOpen.Annotations.ArcLengthDimension")
                {
                    NXOpen.Annotations.ArcLengthDimension dimension = (NXOpen.Annotations.ArcLengthDimension)nNXObject;
                    return(oldColor = dimension.Color);
                }
                else if (DimenType == "NXOpen.Annotations.AngularDimension")
                {
                    NXOpen.Annotations.AngularDimension dimension = (NXOpen.Annotations.AngularDimension)nNXObject;
                    return(oldColor = dimension.Color);
                }
                else if (DimenType == "NXOpen.Annotations.ParallelDimension")
                {
                    NXOpen.Annotations.ParallelDimension dimension = (NXOpen.Annotations.ParallelDimension)nNXObject;
                    return(oldColor = dimension.Color);
                }
            }
            catch (System.Exception ex)
            {
            }
            return(oldColor);
        }
Beispiel #2
0
 private static void GetTextBoxCoordinate(string DimeType, NXObject singleObj, out CaxME.BoxCoordinate cBoxCoordinate)
 {
     cBoxCoordinate = new CaxME.BoxCoordinate();
     if (DimeType == "NXOpen.Annotations.VerticalDimension")
     {
         #region VerticalDimension取Location
         NXOpen.Annotations.VerticalDimension temp = (NXOpen.Annotations.VerticalDimension)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.PerpendicularDimension")
     {
         #region PerpendicularDimension取Location
         NXOpen.Annotations.PerpendicularDimension temp = (NXOpen.Annotations.PerpendicularDimension)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.MinorAngularDimension")
     {
         #region MinorAngularDimension取Location
         NXOpen.Annotations.MinorAngularDimension temp = (NXOpen.Annotations.MinorAngularDimension)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.MajorAngularDimension")
     {
         #region MajorAngularDimension取Location
         NXOpen.Annotations.MajorAngularDimension temp = (NXOpen.Annotations.MajorAngularDimension)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.RadiusDimension")
     {
         #region MinorAngularDimension取Location
         NXOpen.Annotations.RadiusDimension temp = (NXOpen.Annotations.RadiusDimension)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.HorizontalDimension")
     {
         #region HorizontalDimension取Location
         NXOpen.Annotations.HorizontalDimension temp = (NXOpen.Annotations.HorizontalDimension)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.IdSymbol")
     {
         #region IdSymbol取Location
         NXOpen.Annotations.IdSymbol temp = (NXOpen.Annotations.IdSymbol)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.Note")
     {
         #region Note取Location
         NXOpen.Annotations.Note temp = (NXOpen.Annotations.Note)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.DraftingFcf")
     {
         #region DraftingFcf取Location
         NXOpen.Annotations.DraftingFcf temp = (NXOpen.Annotations.DraftingFcf)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.Label")
     {
         #region Label取Location
         NXOpen.Annotations.Label temp = (NXOpen.Annotations.Label)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.DraftingDatum")
     {
         #region DraftingDatum取Location
         NXOpen.Annotations.DraftingDatum temp = (NXOpen.Annotations.DraftingDatum)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.DiameterDimension")
     {
         #region DiameterDimension取Location
         NXOpen.Annotations.DiameterDimension temp = (NXOpen.Annotations.DiameterDimension)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.AngularDimension")
     {
         #region AngularDimension取Location
         NXOpen.Annotations.AngularDimension temp = (NXOpen.Annotations.AngularDimension)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.CylindricalDimension")
     {
         #region CylindricalDimension取Location
         NXOpen.Annotations.CylindricalDimension temp = (NXOpen.Annotations.CylindricalDimension)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.ChamferDimension")
     {
         #region ChamferDimension取Location
         NXOpen.Annotations.ChamferDimension temp = (NXOpen.Annotations.ChamferDimension)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.HoleDimension")
     {
         #region HoleDimension取Location
         NXOpen.Annotations.HoleDimension temp = (NXOpen.Annotations.HoleDimension)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         //CaxLog.ShowListingWindow(cBoxCoordinate.lower_left[0].ToString());
         //CaxLog.ShowListingWindow(cBoxCoordinate.lower_left[1].ToString());
         //CaxLog.ShowListingWindow(cBoxCoordinate.lower_right[0].ToString());
         //CaxLog.ShowListingWindow(cBoxCoordinate.lower_right[1].ToString());
         //CaxLog.ShowListingWindow(cBoxCoordinate.upper_right[0].ToString());
         //CaxLog.ShowListingWindow(cBoxCoordinate.upper_right[1].ToString());
         //CaxLog.ShowListingWindow(cBoxCoordinate.upper_left[0].ToString());
         //CaxLog.ShowListingWindow(cBoxCoordinate.upper_left[1].ToString());
         //CaxLog.ShowListingWindow("----");
         //CaxME.DrawTextBox(temp.Tag);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.ParallelDimension")
     {
         #region ParallelDimension取Location
         NXOpen.Annotations.ParallelDimension temp = (NXOpen.Annotations.ParallelDimension)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.FoldedRadiusDimension")
     {
         #region FoldedRadiusDimension取Location
         NXOpen.Annotations.FoldedRadiusDimension temp = (NXOpen.Annotations.FoldedRadiusDimension)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.ArcLengthDimension")
     {
         #region ArcLengthDimension取Location
         NXOpen.Annotations.ArcLengthDimension temp = (NXOpen.Annotations.ArcLengthDimension)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.DraftingSurfaceFinish")
     {
         #region SurfaceFinish取Location
         NXOpen.Annotations.DraftingSurfaceFinish temp = (NXOpen.Annotations.DraftingSurfaceFinish)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.ConcentricCircleDimension")
     {
         #region ConcentricCircle取Location
         NXOpen.Annotations.ConcentricCircleDimension temp = (NXOpen.Annotations.ConcentricCircleDimension)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
     else if (DimeType == "NXOpen.Annotations.Gdt")
     {
         #region GDT Symbol取Location
         NXOpen.Annotations.Gdt temp = (NXOpen.Annotations.Gdt)singleObj;
         CaxME.GetTextBoxCoordinate(temp.Tag, out cBoxCoordinate);
         #endregion
     }
 }
Beispiel #3
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);
        }