Beispiel #1
0
        /////////////////////////////////////////////////////////////
        // Use: Returns thread type as string.
        //
        /////////////////////////////////////////////////////////////
        public static string GetThreadTypeStr(PartFeature feature)
        {
            if (feature.Type == ObjectTypeEnum.kHoleFeatureObject)
            {
                return("Standard");
            }

            if (feature.Type == ObjectTypeEnum.kThreadFeatureObject || feature.Type == ObjectTypeEnum.kThreadFeatureProxyObject)
            {
                ThreadFeature thread = feature as ThreadFeature;

                return(thread.ThreadInfoType ==
                       ThreadTypeEnum.kStandardThread ?
                       "Standard" : "Tapered");
            }

            return("Invalid Feature");
        }
Beispiel #2
0
        /////////////////////////////////////////////////////////////
        // Use: Ok Button clicked Handler
        //
        /////////////////////////////////////////////////////////////
        private void bOk_Click(object sender, EventArgs e)
        {
            bool silentOp = _Application.SilentOperation;

            _Application.SilentOperation = true;

            PartDocument template = _Application.Documents.Open(
                _ThreadTemplatePath, false) as PartDocument;

            _Application.SilentOperation = silentOp;

            if (!ValidateTemplateParameters(template))
            {
                DialogResult res = MessageBox.Show(
                    "Missing sketch parameter in template file!",
                    "Invalid Template",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);

                bOk.Enabled = false;

                _ThreadTemplatePath = string.Empty;

                tbTemplate.Text = string.Empty;

                if (template != _Application.ActiveDocument)
                {
                    template.Close(true);
                }

                return;
            }

            List <ThreadFeature> threads = new List <ThreadFeature>();

            foreach (System.Object selectedObj in
                     _InteractionManager.SelectedEntities)
            {
                ThreadFeature thread = selectedObj as ThreadFeature;

                if (thread.Suppressed)
                {
                    continue;
                }

                threads.Add(thread);
            }

            PlanarSketch templateSketch =
                template.ComponentDefinition.Sketches[1];



            if (!ThreadWorker.ModelizeThreads(
                    _Document,
                    templateSketch,
                    threads,
                    _extraPitch))
            {
                DialogResult res = MessageBox.Show(
                    "Failed to create CoilFeature... " +
                    "Try with a bigger Pitch Offset value",
                    "Modelization Error",
                    MessageBoxButtons.OKCancel,
                    MessageBoxIcon.Error);

                switch (res)
                {
                case DialogResult.OK:
                    //template.Close(true);
                    return;

                default:
                    break;
                }
            }

            // Problem: closing the template doc here
            // will empty the undo stack (as designed)...

            //template.Close(true);
            if (!_cleaned)
            {
                CleanUp();
            }
            _InteractionManager.Terminate();
        }
Beispiel #3
0
        /////////////////////////////////////////////////////////////
        // Use: OnSelect ThreadFeature Handler.
        //
        /////////////////////////////////////////////////////////////
        void SelectEvents_OnSelect(
            ObjectsEnumerator JustSelectedEntities,
            SelectionDeviceEnum SelectionDevice,
            Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            foreach (System.Object obj in JustSelectedEntities)
            {
                PartFeature feature = obj as PartFeature;

                ThreadFeature thread = obj as ThreadFeature;

                ThreadInfo threadInfo = thread.ThreadInfo;

                Face threadedFace = thread.ThreadedFace[1];


                if (feature.Suppressed)
                {
                    continue;
                }

                if (thread.ThreadInfoType == ThreadTypeEnum.kTaperedThread &&
                    threadedFace.SurfaceType != SurfaceTypeEnum.kConeSurface)
                {
                    DialogResult res = MessageBox.Show(
                        "Threaded face surface type is not cone surface but it is applied" +
                        System.Environment.NewLine +
                        "with tapered thread. ThreadModeler cannot modelize this thread.",
                        "Invalid Surface Type",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    continue;
                }

                string iMateName = string.Empty;

                if (Toolkit.HasiMate(threadedFace,
                                     out iMateName))
                {
                    DialogResult res = MessageBox.Show(
                        "Threaded face or one of its edge has" +
                        " iMate associated to it." +
                        System.Environment.NewLine +
                        "Please delete iMate " + iMateName +
                        " before modelizing this thread.",
                        "Invalid iMate",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);

                    continue;
                }

                double pitch = ThreadWorker.GetThreadPitch(threadInfo);

                string pitchStr =
                    ThreadWorker.GetThreadPitchStr(threadInfo,
                                                   (Document)_Document);

                string minStr =
                    _Document.UnitsOfMeasure.GetStringFromValue(
                        ThreadWorker.ThresholdPitchCm,
                        UnitsTypeEnum.kDefaultDisplayLengthUnits);

                if (pitch < ThreadWorker.ThresholdPitchCm)
                {
                    DialogResult res = MessageBox.Show(
                        "Selected thread pitch " +
                        "is too small (" + pitchStr + ")." +
                        System.Environment.NewLine +
                        "The minimum thread pitch that can " +
                        "be modelized is " + minStr + " .",
                        "Invalid Thread Pitch",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);

                    continue;
                }

                ListViewItem item =
                    lvFeatures.Items.Add(feature.Name);

                item.Tag = feature;

                item.SubItems.Add(pitchStr);

                item.SubItems.Add(ThreadWorker.GetThreadTypeStr(
                                      feature));

                item.SubItems.Add(
                    ThreadWorker.GetThreadedFaceTypeStr(
                        threadedFace));
            }

            _selecSetPopulated = (lvFeatures.Items.Count != 0);

            bOk.Enabled = ValidateOkButton();
        }