コード例 #1
0
        public override void OnPreSelect(object preSelectEntity, out bool doHighlight, ObjectCollection morePreSelectEntities, SelectionDeviceEnum selectionDevice, Point modelPosition, Point2d viewPosition, Inventor.View view)
        {
            doHighlight = false;

            if (preSelectEntity is Face)
            {
                Face preSelectFace = (Face)preSelectEntity;

                if (preSelectFace.SurfaceType == SurfaceTypeEnum.kCylinderSurface)
                {
                    PartDocument oPartDoc = (PartDocument)m_inventorApplication.ActiveDocument;

                    iFeatures oiFeatures = oPartDoc.ComponentDefinition.Features.iFeatures;

                    foreach (iFeature oiFeature in oiFeatures)
                    {
                        Faces oFaces;
                        oFaces = oiFeature.Faces;
                        foreach (Face oFace in oFaces)
                        {
                            if (oFace == preSelectFace)
                            {
                                doHighlight = true;
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        //由选择曲面获取iFeature特征
        private void GetiFeature(ExtrudeFeature surfaceFeature, ref iFeature ifeature)
        {
            string ifeatureName;

            try
            {
                AttributeSets surfAttributeSets;
                surfAttributeSets = surfaceFeature.AttributeSets;

                AttributeSet surfAttibSet;
                surfAttibSet = surfaceFeature.AttributeSets["MyAttribSet"];

                ifeatureName = (string)surfAttibSet["iFeatureName"].Value;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("获取属性集失败!  " + ex.ToString());
                return;
            }

            //获取iFeature
            PartDocument oPartDoc   = (PartDocument)m_inventorApplication.ActiveDocument;
            iFeatures    oiFeatures = oPartDoc.ComponentDefinition.Features.iFeatures;

            ifeature = oiFeatures[ifeatureName];
        }