コード例 #1
0
        public static bool CreateToolUf()
        {
            try
            {
                Tag newToolTag;
                //指定刀具的Type(與所在樣板檔同名)
                string toolType = "turning";
                //指定刀具的Subtype
                string toolSubtype = "OD_80_R";
                //建立刀具
                theUfSession.Cutter.Create(toolType, toolSubtype, out newToolTag);

                //取得CAM Setup
                CAMSetup theCamSetup = theSession.Parts.Work.CAMSetup;

                //取得Machine Tool view的Root
                Tag machineToolRootTag;
                theUfSession.Setup.AskMctRoot(theCamSetup.Tag, out machineToolRootTag);

                //將Tool Tag移到Machine Tool Root下
                theUfSession.Ncgroup.AcceptMember(machineToolRootTag, newToolTag);



                //從toolData(來自DB)設定刀具參數
                //theUfSession.Param.SetStrValue(newToolTag, UFConstants.UF_PARAM_TL_DESCRIPTION, "HAHAHA"); //刀具名稱
                //theUfSession.Param.SetDoubleValue(newToolTag, UFConstants.UF_PARAM_TL_DIAMETER, toolData.diameter); //刀具直徑
                //theUfSession.Param.SetDoubleValue(newToolTag, UFConstants.UF_PARAM_TL_HEIGHT, toolData.fully_length); //刀具全長
                //theUfSession.Param.SetDoubleValue(newToolTag, UFConstants.UF_PARAM_TL_FLUTE_LN, toolData.first_length); //刀具刃長
                //theUfSession.Param.SetDoubleValue(newToolTag, UFConstants.UF_PARAM_TL_COR1_RAD, toolData.tool_point); //刀尖R角
                //theUfSession.Param.SetIntValue(newToolTag, UFConstants.UF_PARAM_TL_NUM_FLUTES, toolData.edge_num); //刃數
            }
            catch (System.Exception ex)
            {
                return(false);
            }
            return(true);
        }
コード例 #2
0
        private static double[] GetWorkpieseDimension(List <FeatureGeometry> featureGeometryList, CAMSetup setup)
        {
            double[] tempArray          = new double[6];
            double[] workpieceDimension = new double[3] {
                -1, -1, -1
            };

            if (featureGeometryList.Count < 1)
            {
                Guide.InfoWriteLine("Warning!! The Program Head can't be filled with workpiece dimension!!!");
                Guide.InfoWriteLine("There is also a danger that your machine will be CRASHED!");
                Guide.InfoWriteLine("Exam your workpiece in Operation Setup!!!");
                return(workpieceDimension);
            }

            NXOpen.CAM.FeatureGeometry featureGeometry = featureGeometryList[0];
            NXOpen.CAM.MillGeomBuilder geomBuilder     = setup.CAMGroupCollection.CreateMillGeomBuilder(featureGeometry);
            TaggedObject taggedObject = geomBuilder.GetCustomizableItemBuilder("Raw Material");
            TaggedObject partGeometry;

            NXOpen.CAM.Geometry geometry;

            if (taggedObject != null)
            {
                //"Hybrid Geometry"
                geometry     = (Geometry)taggedObject;
                partGeometry = (TaggedObject)geometry.GeometryList.GetContents()[0].GetItems()[0];
            }
            else
            {
                //Milling Geometry
                partGeometry = (TaggedObject)geomBuilder.PartGeometry.GeometryList.GetContents()[0].GetItems()[0];
            }

            Body body = (Body)partGeometry;

            _theUfSession.Modl.AskBoundingBox(body.Tag, tempArray);

            workpieceDimension[0] = tempArray[3] - tempArray[0];
            workpieceDimension[1] = tempArray[4] - tempArray[1];
            workpieceDimension[2] = tempArray[5] - tempArray[2];

            return(workpieceDimension);
        }