Example #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);
        }
Example #2
0
        private vdPolyface AddMeshToEntities(vdEntities entities, MeshData mesh)
        {
            vdPolyface onepolyface = new vdPolyface();

            onepolyface.SetUnRegisterDocument(vDraw.ActiveDocument);
            onepolyface.setDocumentDefaults();

            // 顶点数组输入
            foreach (PointData point in mesh.Vertexes)
            {
                onepolyface.VertexList.Add(point.X * Tools.Ft2MmScale, point.Y * Tools.Ft2MmScale, point.Z * Tools.Ft2MmScale);
            }

            // 面片索引输入
            foreach (TriangleIndexData index in mesh.TriangleIndexes)
            {
                onepolyface.AddFaceItem(index.V1 + 1, index.V2 + 1, index.V3 + 1, index.V1 + 1, -1);
            }

            onepolyface.SmoothAngle = 45;
            onepolyface.Layer       = vDraw.ActiveDocument.Layers.FindName(mesh.MaterialName);
            entities.Add(onepolyface);

            if (ExportSetting.SystemSetting.IsExportTextureFile)
            {
                var material = Materials.Find(m => m.Name == mesh.MaterialName);
                if (material != null && !string.IsNullOrEmpty(material.GetValidMapFile()))
                {
                    var img = vDraw.ActiveDocument.Images.FindName(Path.GetFileNameWithoutExtension(material.GetValidMapFile()));
                    if (img != null)
                    {
                        onepolyface.PenColor.SystemColor   = Color.Gray;
                        onepolyface.PenColor.MaterialImage = img;

                        Matrix mtx = new Matrix();
                        mtx.IdentityMatrix();
                        mtx.ScaleMatrix(0.001, 0.001, 1);
                        onepolyface.PenColor.MaterialMatrix = mtx;
                    }
                }
            }

            onepolyface.Invalidate();
            onepolyface.Update();

            return(onepolyface);
        }
Example #3
0
        private void AddPipeToEntities(vdEntities entities, double diameter, gPoint ptStart, gPoint ptEnd, string layerName)
        {
            var pf = new vdPolyface();

            pf.SetUnRegisterDocument(vDraw.ActiveDocument);
            pf.setDocumentDefaults();

            var line   = new vdLine(ptStart, ptEnd);
            var circle = new vdCircle
            {
                Radius = diameter / 2.0
            };

            pf.Generate3dPathSection(line, circle, new gPoint(0, 0, 0), 6, 1);
            pf.Layer       = vDraw.ActiveDocument.Layers.FindName(layerName);
            pf.SmoothAngle = 45;
            entities.Add(pf);
        }