Example #1
0
        static bool IsSheetMetalPart(IPartDoc swPart)
        {
            try
            {
                var isSheet = false;

                var vBodies = swPart.GetBodies2((int)swBodyType_e.swSolidBody, false);

                foreach (Body2 vBody in vBodies)
                {
                    try
                    {
                        var isSheetMetal = vBody.IsSheetMetal();
                        if (!isSheetMetal)
                        {
                            continue;
                        }
                        isSheet = true;
                    }
                    catch
                    {
                        isSheet = false;
                    }
                }

                return(isSheet);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
                return(false);
            }
        }
Example #2
0
        static bool IsSheetMetalPart(IPartDoc swPart)
        {
            try
            {
                var isSheet = false;

                var vBodies = swPart.GetBodies2((int)swBodyType_e.swSolidBody, false);

                foreach (Body2 vBody in vBodies)
                {
                    try
                    {
                        var isSheetMetal = vBody.IsSheetMetal();
                        if (!isSheetMetal) continue;
                        isSheet = true;
                    }
                    catch
                    {
                        isSheet = false;
                    }
                }

                return isSheet;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
                return false;
            }
        }
        /// <summary>
        /// Check is sheet metal part
        /// </summary>
        /// <param name="swPart"></param>
        public static bool IsSheetMetalPart(IPartDoc swPart)
        {
            bool isSheetMetal = false;

            try
            {
                var bodies = swPart.GetBodies2((int)swBodyType_e.swSolidBody, false);
                foreach (Body2 body in bodies)
                {
                    isSheetMetal = body.IsSheetMetal();

                    MessageBox.Show("Check is sheet metal part; returned " + isSheetMetal);

                    if (isSheetMetal)
                    {
                        return(true);
                    }
                }
            }
            catch (System.Exception)
            {
                MessageBox.Show("Failed check is sheet metal part; returned " + false);
                return(false);
            }
            return(isSheetMetal);
        }
Example #4
0
        static bool IsSheetMetalPart(IPartDoc swPart)
        {
            var isSheetMetal = false;
            var vBodies      = swPart.GetBodies2((int)swBodyType_e.swSolidBody, false);

            foreach (Body2 vBody in vBodies)
            {
                isSheetMetal = vBody.IsSheetMetal();
            }
            return(isSheetMetal);
        }
Example #5
0
        public static IEnumerable <IBody2> GetBodiesEx(this IPartDoc doc, swBodyType_e bodyType = swBodyType_e.swSolidBody, bool withInvisbleBody = false)
        {
            object[] bodies = doc.GetBodies2((int)bodyType, !withInvisbleBody) as object[];

            if (bodies == null)
            {
                yield break;
            }

            foreach (var item in bodies)
            {
                yield return(item as IBody2);
            }
        }
Example #6
0
        private IEnumerable <IBody2> ConvertBodiesContext(IEnumerable <IBody2> inputBodies, IPartDoc context)
        {
            var partBodies = (context.GetBodies2((int)swBodyType_e.swAllBodies, false) as object[]).Cast <IBody2>();

            return(inputBodies.Select(b =>
            {
                var corrBody = partBodies.FirstOrDefault(
                    pb => pb.Name.Equals(b.Name, StringComparison.CurrentCultureIgnoreCase));

                if (corrBody == null)
                {
                    throw new NullReferenceException(string.Format("Failed to find the corresponding body of {0}", b.Name));
                }

                return corrBody;
            }).ToArray());
        }
Example #7
0
        private IBody2 GetBodyToProcess(IPartDoc part, object inputObj)
        {
            if (inputObj is IFace2)
            {
                return((inputObj as IFace2).GetBody() as IBody2);
            }
            else
            {
                object[] solidBodies = part.GetBodies2((int)swBodyType_e.swSolidBody, true) as object[];

                if (solidBodies != null && solidBodies.Length == 1)
                {
                    return(solidBodies[0] as IBody2);
                }
            }

            throw new NullReferenceException("Failed to find the input body. Either select cylindrical face or use single body part");
        }
Example #8
0
        public static bool IsSheetMetalPart(IPartDoc swPart)
        {
            var isSheetMetal = false;

            try
            {
                var vBodies = swPart.GetBodies2((int)swBodyType_e.swSolidBody, false);

                foreach (Body2 vBody in vBodies)
                {
                    isSheetMetal = vBody.IsSheetMetal();
                    if (isSheetMetal)
                    {
                        return(true);
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(isSheetMetal);
        }
Example #9
0
        /// <summary>
        /// Check is sheet metal part
        /// </summary>
        /// <param name="swPart"></param>
        /// <returns></returns>
        public static bool IsSheetMetalPart(IPartDoc swPart)
        {
            var isSheetMetal = false;

            try
            {
                var bodies = swPart.GetBodies2((int)swBodyType_e.swSolidBody, false);
                foreach (Body2 body in bodies)
                {
                    isSheetMetal = body.IsSheetMetal();
                    if (isSheetMetal)
                    {
                        MessageObserver.Instance.SetMessage("Check is sheet metal part; returned " + isSheetMetal, MessageType.Success);
                        return(true);
                    }
                }
            }
            catch (Exception)
            {
                MessageObserver.Instance.SetMessage("Failed check is sheet metal part; returned " + false, MessageType.Success);
                return(false);
            }
            return(isSheetMetal);
        }
Example #10
0
                static bool IsSheetMetalPart(IPartDoc swPart)
                {
                    var isSheet = false;

                    //var mod = (IModelDoc2)swPart;

                    var vBodies = swPart.GetBodies2((int)swBodyType_e.swSolidBody, false);

                    foreach (Body2 vBody in vBodies)
                    {
                        try
                        {
                            var isSheetMetal = vBody.IsSheetMetal();
                            if (!isSheetMetal) continue;
                            isSheet = true;
                        }
                        catch
                        {
                            isSheet = false;
                        }
                    }

                    return isSheet;
                }
Example #11
0
        private static bool IsSheetMetalPart(IPartDoc swPart)
        {
            var isSheetMetal = false;
            try
            {
                var vBodies = swPart.GetBodies2((int) swBodyType_e.swSolidBody, false);

                foreach (Body2 vBody in vBodies)
                {
                    isSheetMetal = vBody.IsSheetMetal();
                }
                return isSheetMetal;
            }
            catch (Exception)
            {
                //  
            }
            return isSheetMetal;
        }