Exemple #1
0
        private vdInsert AddInsertToEntities(vdEntities entities, InsertData ins)
        {
            //var blk = vDraw.ActiveDocument.Blocks.FindName(ins.BlockRef.Name) ?? CreateBlock(ins.BlockRef);
            var blk = vDraw.ActiveDocument.Blocks.FindName(ins.BlockName) ?? CreateBlock(DictBlocks[ins.BlockName]);

            if (blk == null)
            {
                //MessageBox.Show("块创建失败!");
                return(null);
            }

            vdInsert insEntity = new vdInsert(vDraw.ActiveDocument)
            {
                Block = blk
            };

            AddXProperties(insEntity, ins);

            Matrix mtx = ChangeTransMatrix(ins.TransMatrix);

            insEntity.Transformby(mtx);
            insEntity.InsertionPoint *= Tools.Ft2MmScale;
            entities.Add(insEntity);
            return(insEntity);
        }
Exemple #2
0
        private void MoveProperty()
        {
            List <string> list1 = new List <string>
            {
                "工序编码",
                "合约类型编码1",
                "合约类型编码2",
                "合约类型代码1",
                "合约类型代码2",
                "清单编码",
                //"结构材质",
                "类型名称"
            };


            foreach (vdFigure vdl in this.vDraw.ActiveDocument.ActiveLayOut.Entities)
            {
                if (vdl is vdInsert)
                {
                    vdInsert vdi = vdl as vdInsert;
                    vdBlock  vdb = vdi.Block;
                    foreach (string str in list1)
                    {
                        var prop = GetFigurePropByName(vdb, str);
                        if (prop != null)
                        {
                            vdi.Props += str + "=" + prop + "\r\n";
                        }
                    }
                    vdb.Props = string.Empty;
                }
            }
        }
Exemple #3
0
        private void InitEntityInModelBlock()
        {
            if (ModelBlock == null)
            {
                return;
            }

            foreach (MeshData mesh in ModelBlock.Meshs)
            {
                vdPolyface vdp = AddMeshToEntities(vDraw.ActiveDocument.ActiveLayOut.Entities, mesh);
                if (vdp != null && ExportSetting.SystemSetting.DefaultLayerName.Length > 1)
                {
                    SetEntityLayer(vdp, ExportSetting.SystemSetting.DefaultLayerName);
                }
            }

            foreach (InsertData ins in ModelBlock.Inserts)
            {
                vdInsert vdi = AddInsertToEntities(vDraw.ActiveDocument.ActiveLayOut.Entities, ins);
                if (vdi != null && ExportSetting.SystemSetting.DefaultLayerName.Length > 1)
                {
                    SetEntityLayer(vdi, ExportSetting.SystemSetting.DefaultLayerName);
                }
            }

            vDraw.ActiveDocument.CommandAction.Zoom("E", null, null);
        }
Exemple #4
0
        private void AddXProperties(vdInsert insEntity, InsertData ins)
        {
            if (ins.DictProperties.Count < 1)
            {
                return;
            }

            AddXPropertiesToEntity(ins.DictProperties, insEntity);
        }
Exemple #5
0
        private void CreatePoint(ModelPoint pt, double radius)
        {
            vdInsert vdi = new vdInsert(vDraw.ActiveDocument, GetSphereBlk(), new gPoint(pt.x, pt.y, pt.z), 0, radius, radius, radius);

            vDraw.ActiveDocument.ActiveLayOut.Entities.Add(vdi);

            vdXProperty vdx = new vdXProperty();

            vdx.Name      = "#PointName";
            vdx.PropValue = pt.Name;
            vdi.XProperties.Add(vdx);

            vDraw.ActiveDocument.Redraw(false);
        }
Exemple #6
0
        /// <summary>
        /// Initializes the dialog.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditCreateBlock_Load(object sender, EventArgs e)
        {
            vdFramedControl1.BaseControl.ActiveDocument.New();
            if (mblk == null)
            {
                textName.Text = "";
                butAddInsertionPoint.Enabled = true;
            }
            else
            {
                textName.Text = mblk.Name;
                butAddInsertionPoint.Enabled = false;

                vdBlock block = new vdBlock();
                block.SetUnRegisterDocument(vdFramedControl1.BaseControl.ActiveDocument);
                block.setDocumentDefaults();
                block.MatchProperties(mblk, vdFramedControl1.BaseControl.ActiveDocument);
                vdFramedControl1.BaseControl.ActiveDocument.Blocks.AddItem(block);

                vdInsert ins = new vdInsert();
                ins.SetUnRegisterDocument(vdFramedControl1.BaseControl.ActiveDocument);
                ins.setDocumentDefaults();
                ins.Block = block;
                vdFramedControl1.BaseControl.ActiveDocument.Model.Entities.AddItem(ins);
                vdFramedControl1.BaseControl.ActiveDocument.CommandAction.CmdExplode(ins);
                ins.Deleted = true;

                vdPoint pt = new vdPoint();
                pt.SetUnRegisterDocument(vdFramedControl1.BaseControl.ActiveDocument);
                pt.setDocumentDefaults();
                pt.InsertionPoint       = new gPoint();
                pt.PenColor.SystemColor = Color.Red;
                pt.Label = "VD_TMP_ORIGIN";
                vdFramedControl1.BaseControl.ActiveDocument.Model.Entities.AddItem(pt);

                vdFramedControl1.BaseControl.ActiveDocument.CommandAction.Zoom("E", 0, 0);
                vdFramedControl1.BaseControl.ActiveDocument.CommandAction.Zoom("S", 0.95, 0);
                vdFramedControl1.BaseControl.ActiveDocument.Redraw(true);
            }
            vdFramedControl1.BaseControl.ActiveDocument.OnUndoStoreValue += new vdDocument.UndoStoreValueEventHandler(ActiveDocument_OnUndoStoreValue);
            //LOAD EditBlocksCOMMANDS / EditBlocksMENU
            vdFramedControl1.UnLoadCommands();
            vdFramedControl1.UnLoadMenu();
            vdFramedControl1.LoadCommands(GetResourcesPath(), "BlockLibraryCommands.txt");
            vdFramedControl1.LoadMenu(GetResourcesPath(), "BlockLibraryMenu.txt");
            vdFramedControl1.ShowMenu(true);
        }
Exemple #7
0
        /// <summary>
        /// Draws to the preview component the block indicated by the parameter.
        /// </summary>
        /// <param name="selectedname">The name of the block to be displayed.</param>
        private void DrawPreview(string selectedname)
        {
            this.vectorDrawBaseControl1.ActiveDocument.Model.Entities.RemoveAll();
            if (selectedname != null && selectedname != "")
            {
                this.vectorDrawBaseControl1.ActiveDocument.Palette.Background = mdoc.Palette.Background;
                vdInsert ins = new vdInsert();
                ins.SetUnRegisterDocument(vectorDrawBaseControl1.ActiveDocument);
                ins.setDocumentDefaults();
                ins.Block = vectorDrawBaseControl1.ActiveDocument.Blocks.FindName(selectedname);

                vectorDrawBaseControl1.ActiveDocument.Model.Entities.AddItem(ins);
                vectorDrawBaseControl1.ActiveDocument.CommandAction.Zoom("E", 0, 0);
                vectorDrawBaseControl1.ActiveDocument.CommandAction.Zoom("S", 0.95, 0);
            }
            vectorDrawBaseControl1.ActiveDocument.Redraw(true);
        }
Exemple #8
0
        /// <summary>
        /// 处理车位编号
        /// </summary>
        /// <returns></returns>
        void ProCarNum(vdDocument doc, string PropName, double width, double height)
        {
            foreach (vdFigure vdf in doc.ActiveLayOut.Entities)
            {
                if (vdf is vdInsert)
                {
                    vdInsert vdi = vdf as vdInsert;

                    vdXProperty vdx = vdi.XProperties.FindName(PropName);
                    if (vdx != null)
                    {
                        //删除原来的文字
                        vdBlock vdb = vdi.Block;
                        for (int i = vdb.Entities.Count - 1; i >= 0; i--)
                        {
                            if (vdb.Entities[i] is vdText)
                            {
                                vdb.Entities.RemoveAt(i);
                            }
                        }
                        //文字样式
                        vdTextstyle vdts = doc.TextStyles.FindName("车位编号");
                        if (vdts == null)
                        {
                            vdts        = new vdTextstyle(doc);
                            vdts.Height = height / 5.0;
                        }
                        //字体
                        vdText vdt = new vdText(doc);
                        vdt.Style      = vdts;
                        vdt.TextString = vdx.PropValue.ToString();
                        vdt.HorJustify = VectorDraw.Professional.Constants.VdConstHorJust.VdTextHorCenter;
                        vdt.VerJustify = VectorDraw.Professional.Constants.VdConstVerJust.VdTextVerCen;


                        Box bb = vdb.BoundingBox();
                        vdt.InsertionPoint = new gPoint(bb.MidPoint.x, bb.Min.y + height / 2.0, bb.Min.z);
                        vdb.Entities.Add(vdt);
                    }
                }
            }
        }
Exemple #9
0
 void ProInsert(vdInsert vdi)
 {
 }
Exemple #10
0
        /// <summary>
        /// 替换字体
        /// </summary>
        /// <param name="vdbs"></param>
        private void ReplaceText(vdBlocks vdbs, vdDocument doc, double width, double height, string PropName)
        {
            //doc.Purge();
            Dictionary <string, string> BlksMap    = new Dictionary <string, string>();
            Dictionary <string, string> BlksMapTmp = new Dictionary <string, string>();

            //删除车位编号
            foreach (vdFigure vdf in doc.ActiveLayOut.Entities)
            {
                if (vdf is vdInsert)
                {
                    vdInsert    vdi = vdf as vdInsert;
                    vdXProperty vdx = vdi.XProperties.FindName(PropName);
                    if (vdx != null)
                    {
                        string  strName = vdx.PropValue.ToString();
                        vdBlock vdb     = vdi.Block;
                        Box     box     = vdb.BoundingBox();

                        Box textbox            = new Box(new gPoint(box.MidPoint.x - width / 2.0, box.Min.y), new gPoint(box.MidPoint.x + width / 2.0, box.Min.y + height));
                        vdArray <vdFigure> vda = new vdArray <vdFigure>();
                        foreach (vdFigure vdff in vdb.Entities)
                        {
                            if (vdff is vdPolyface)
                            {
                                if (vdff.BoundingBox.BoxInBox(textbox))
                                {
                                    vda.AddItem(vdff);
                                }
                            }
                        }

                        Box b = new Box();
                        foreach (vdFigure vdf1 in vda)
                        {
                            b.AddBox(vdf1.BoundingBox);
                            vdb.Entities.RemoveItem(vdf1);
                        }

                        //文字样式
                        vdTextstyle vdts = doc.TextStyles.FindName("车位编号");
                        if (vdts == null)
                        {
                            vdts        = new vdTextstyle(doc);
                            vdts.Name   = "车位编号";
                            vdts.Height = b.Height;
                            //MessageBox.Show(b.Height.ToString());
                            doc.TextStyles.Add(vdts);
                        }

                        //文字
                        vdText vdt = new vdText(doc);
                        vdt.Style          = vdts;
                        vdt.TextString     = vdx.PropValue.ToString();
                        vdt.HorJustify     = VectorDraw.Professional.Constants.VdConstHorJust.VdTextHorCenter;
                        vdt.VerJustify     = VectorDraw.Professional.Constants.VdConstVerJust.VdTextVerCen;
                        vdt.InsertionPoint = b.MidPoint;
                        vdb.Entities.AddItem(vdt);

                        vdf.Invalidate();
                        vdf.Update();
                        string ssss = GetBlkMd5(vdi.Block);

                        if (!BlksMap.ContainsKey(vdi.Block.Name))
                        {
                            BlksMap.Add(vdi.Block.Name, ssss);
                        }
                        else
                        {
                            MessageBox.Show("可能存在重复编号的车位,请仔细查看!");
                        }
                    }
                }
            }

            //查找md5的计数

            Dictionary <string, int> md5count = new Dictionary <string, int>();

            foreach (KeyValuePair <string, string> kv in BlksMap)
            {
                if (!md5count.ContainsKey(kv.Value))
                {
                    md5count.Add(kv.Value, 1);
                }
                else
                {
                    md5count[kv.Value]++;
                }
            }

            foreach (KeyValuePair <string, string> kv in BlksMap)
            {
                if (md5count[kv.Value] > 1)
                {
                    vdBlock vdb2 = doc.Blocks.FindName(kv.Value);
                    vdBlock vdb  = doc.Blocks.FindName(kv.Key);
                    if (vdb2 == null)  //md5码的块不存在的话
                    {
                        if (vdb != null)
                        {
                            vdBlock vdb1 = vdb.Clone(doc) as vdBlock;
                            for (int i = vdb1.Entities.Count - 1; i >= 0; i--)
                            {
                                if (vdb1.Entities[i] is vdText)
                                {
                                    vdb1.Entities.RemoveItem(vdb1.Entities[i]);
                                }
                            }
                            vdb1.Name = kv.Value;
                            doc.Blocks.Add(vdb1);
                        }
                    }
                    //原来的内容作为一个块,加进去

                    for (int i = vdb.Entities.Count - 1; i >= 0; i--)
                    {
                        if (!(vdb.Entities[i] is vdText))
                        {
                            vdb.Entities.RemoveItem(vdb.Entities[i]);
                        }
                    }

                    //vdb.Entities.RemoveAll();
                    vdInsert vdi = new vdInsert(doc);
                    vdi.Block = doc.Blocks.FindName(kv.Value);  //
                    vdb.Entities.Add(vdi);

                    //将字体加上去

                    vdb.Update();
                }
            }

            //ProCarNum(doc, PropName, width, height);  //处理车位编号
        }