Example #1
0
        /// <summary>
        /// 线程图纸标注函数;
        /// </summary>
        /// <param name="message"></param>
        private void DimDrawingThreadFunc(object message)
        {
            DrawingHandler drawingHandler = new DrawingHandler();

            int nIndex = 0;
            int nCount = mrAssemblyDrawingList.Count;

            mMainForm.SetWholeProgressMax(nCount);

            string strCurrentTips = "";
            string strWholeTips   = "";

            foreach (CMrAssemblyDrawing mrDrawing in mrAssemblyDrawingList)
            {
                nIndex++;
                mMainForm.SetWholeProgressPos(nIndex);
                strWholeTips = "总进度:" + nIndex + "/" + nCount.ToString();
                mMainForm.SetWholeLabelText(strWholeTips);

                int             nViewIndex                = 0;
                AssemblyDrawing assemblyDrawing           = mrDrawing.mAssemblyDring;
                Identifier      assemblyDrawingIdentifier = assemblyDrawing.AssemblyIdentifier;

                if (assemblyDrawing == null)
                {
                    continue;
                }
                try
                {
                    Assembly assembly = new Assembly
                    {
                        Identifier = assemblyDrawing.AssemblyIdentifier
                    };

                    assembly.Select();
                    Identifier identifier  = assembly.GetMainPart().Identifier;
                    Beam       modelObject = mModel.SelectModelObject(identifier) as Beam;
                    drawingHandler.SetActiveDrawing(assemblyDrawing, true);
                    DrawingObjectEnumerator allViews = assemblyDrawing.GetSheet().GetAllViews();

                    //1.判断是否需要创建自动剖面;
                    if (CCommonPara.mAutoSectionType == MrAutoSectionType.MrListDim || CCommonPara.mAutoSectionType == MrAutoSectionType.MrTwoTypeDim)
                    {
                        CreateAutoSection(mrDrawing.mDimType, modelObject, assemblyDrawing);
                    }

                    int nViewCount = allViews.GetSize();
                    mMainForm.SetCurrentProgressMax(nViewCount);

                    while (allViews.MoveNext())
                    {
                        if (allViews.Current != null)
                        {
                            nViewIndex++;
                            mMainForm.SetCurrentProgressPos(nViewIndex);
                            strCurrentTips = "当前进度:" + nViewIndex + "/" + nViewCount.ToString();
                            mMainForm.SetCurrentLabelText(strCurrentTips);

                            TSD.View view = allViews.Current as TSD.View;
                            if (view != null)
                            {
                                DrawDrawingByView(view, modelObject, mrDrawing.mDimType);
                            }
                        }
                    }
                    assemblyDrawing.IsFrozen = true;
                    assemblyDrawing.PlaceViews();
                    assemblyDrawing.Modify();
                    drawingHandler.SaveActiveDrawing();
                    drawingHandler.CloseActiveDrawing();
                }
                catch (System.Exception ex)
                {
                    string strName = assemblyDrawing.Name;
                    MessageBox.Show("图纸" + strName + "标注失败,请确认模型或图纸内是否有问题。异常信息:" + ex.Message);
                    drawingHandler.SaveActiveDrawing();
                    drawingHandler.CloseActiveDrawing();

                    nIndex++;
                    mMainForm.SetWholeProgressPos(nIndex);
                    strWholeTips = "总进度:" + nIndex + "/" + nCount.ToString();
                    mMainForm.SetWholeLabelText(strWholeTips);
                    continue;
                }
            }

            MessageBox.Show("扬州Tekla培训石头哥提示您标注结束,感谢您对智能标注系统的支持。");
        }