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); }
public override void FillShapeEntities(ref vdEntities entities) { vdCircle circle = new vdCircle(); entities.AddItem(circle); circle.MatchProperties(this, Document); circle.Radius = mRadius; circle.HatchProperties = mhatchprops; if (mShowLines) { gPoint cen = new gPoint(); vdLine line1; double angle = 0.0; for (int i = 0; i < 4; i++) { line1 = new vdLine(); line1.MatchProperties(this, Document); if (mhatchprops.FillMode == VdConstFill.VdFillModeNone) { line1.LineType = Document.LineTypes.Invisible; } line1.StartPoint = new gPoint(gPoint.Polar(cen, angle + mAngle, 3.0d * mRadius / 2.0d)); line1.EndPoint = new gPoint(gPoint.Polar(cen, angle + mAngle, 2.0d * mRadius)); angle += VectorDraw.Geometry.Globals.HALF_PI; entities.AddItem(line1); } } }
public override vdEntities Explode() { vdEntities Entities = new vdEntities(); Entities.SetUnRegisterDocument(Document); if (Document != null) { Document.UndoHistory.PushEnable(false); } vdLine line = new vdLine(); line.StartPoint = StartPoint; line.EndPoint = EndPoint; line.MatchProperties(this, Document); Entities.AddItem(line); vdPolyline pl = new vdPolyline(); pl.VertexList.AddRange(this.mArrowPoints); pl.Flag = VdConstPlineFlag.PlFlagCLOSE; pl.HatchProperties = new vdHatchProperties(); pl.HatchProperties.FillMode = VdConstFill.VdFillModeSolid; pl.HatchProperties.FillColor.ByBlock = true; pl.Transformby(ArrowEcsMatrix(new Vector(0, 0, 1))); pl.MatchProperties(this, Document); Entities.AddItem(pl); if (Document != null) { Document.UndoHistory.PopEnable(); } return(Entities); }
public void clear_previous_pic() { vdEntities arr = this.cf.vdScrollableControl1.BaseControl.ActiveDocument.ActiveLayOut.Entities; arr.RemoveAll(); vdDocument activeDocu = this.cf.vdScrollableControl1.BaseControl.ActiveDocument; activeDocu.Redraw(true); cf.vdScrollableControl1.BaseControl.ActiveDocument.ZoomExtents(); }
public void find_depth() { vdEntities arr = this.vdScrollableControl1.BaseControl.ActiveDocument.ActiveLayOut.Entities; List <vdLine> list = new List <vdLine>(); //arr[arr.Count - 2], arr[arr.Count - 1] vdLine line1 = (vdLine)arr[arr.Count - 2]; vdLine line2 = (vdLine)arr[arr.Count - 1]; if (line1.StartPoint.y >= line2.StartPoint.y) { //line1ÔÚÉÏÃæ list.Add(line1); list.Add(line2); } else { list.Add(line2); list.Add(line1); } // DrawCommonData.startDepth1 List <vdText> depthList = new List <vdText>(); foreach (vdFigure figure in arr) { if (figure is vdText) { vdText text = figure as vdText; try { int depth = int.Parse(text.TextString); if (depth >= DrawCommonData.upperdepth && depth <= DrawCommonData.lowerdepth) { depthList.Add(text); } } catch { continue; } } } int upper = this.find_nearest_depth(depthList, list[0]); //Éî¶ÈÉϽç int lower = this.find_nearest_depth(depthList, list[1]); //Éî¶ÈϽç MessageBox.Show("ÉϽç:" + upper.ToString()); MessageBox.Show("Ͻç:" + lower.ToString()); }
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); }
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); }
private void button1_Click(object sender, EventArgs e) { vdEntities arr = ((Childform)this.ActiveMdiChild).vdScrollableControl1.BaseControl.ActiveDocument.ActiveLayOut.Entities; vdLine beforelastline = arr[arr.Count - 2] as vdLine; vdLine lastline = arr[arr.Count - 1] as vdLine; if (beforelastline != null && lastline != null) { MessageBox.Show("无法画线"); return; } ((Childform)this.ActiveMdiChild).vdScrollableControl1.BaseControl.ActiveDocument.CommandAction.CmdLine(null); }
public override void FillShapeEntities(ref vdEntities entities) { vdCircle circle = new vdCircle(); entities.AddItem(circle); circle.MatchProperties(this, Document); circle.Radius = mRadius; if (mShowLines) { gPoint cen = new gPoint(); vdLine line1; vdPolyline pLine = new vdPolyline(); line1 = new vdLine(); line1.MatchProperties(this, Document); if (mhatchprops.FillMode == VdConstFill.VdFillModeNone) { line1.LineType = Document.LineTypes.Invisible; } line1.StartPoint = circle.Center; double ss = 0.5d; line1.EndPoint = new gPoint(line1.StartPoint.x - ss, line1.StartPoint.y - ss); pLine.MatchProperties(this, Document); pLine.VertexList.Add(line1.StartPoint); //pLine.VertexList.Add(new gPoint(line1.StartPoint.x,line1.StartPoint.y - circle.Radius)); pLine.VertexList.Add(line1.EndPoint); pLine.VertexList.Add(new gPoint(line1.StartPoint.x + ss, line1.StartPoint.y - ss)); pLine.VertexList.Add(pLine.VertexList[0]); //entities.AddItem(line1); entities.AddItem(pLine); } }
public static Box GetBoundingBox(IList <vdFigure> entities) { var vdEntities = new vdEntities(entities.ToArray()); return(vdEntities.GetBoundingBox(true, true)); }
private void find_depth_gap() { vdEntities arr = ((Childform)this.ActiveMdiChild).vdScrollableControl1.BaseControl.ActiveDocument.ActiveLayOut.Entities; List <vdLine> list = new List <vdLine>(); //arr[arr.Count - 2], arr[arr.Count - 1] vdLine line1; vdLine line2; try { line1 = (vdLine)arr[arr.Count - 2]; line2 = (vdLine)arr[arr.Count - 1]; } catch { MessageBox.Show("还没有画线或者线的数目不够2个"); return; } if (line1.StartPoint.y >= line2.StartPoint.y) { //line1在上面 list.Add(line1); list.Add(line2); } else { list.Add(line2); list.Add(line1); } // DrawCommonData.startDepth1 List <vdText> depthList = new List <vdText>(); foreach (vdFigure figure in arr) { if (figure is vdText) { vdText text = figure as vdText; try { int depth = int.Parse(text.TextString); if (depth >= DrawCommonData.upperdepth && depth <= DrawCommonData.lowerdepth) { depthList.Add(text); } } catch { continue; } } } int upper = this.find_nearest_depth(depthList, list[0]); //深度上界 int lower = this.find_nearest_depth(depthList, list[1]); //深度下界 if (upper < 0) { upper = lower - 2; } //MessageBox.Show("上界:" + upper.ToString()); //MessageBox.Show("下界:" + lower.ToString()); MessageBox.Show(upper.ToString() + "-" + lower.ToString()); BaseLineForm.depthmin = upper; BaseLineForm.depthmax = lower; }
public override void FillShapeEntities(ref vdEntities entities) { //calculate shape entities in ecs gPoint cen = new gPoint(); vdText text = new vdText(); //entities.AddItem(text); //text.MatchProperties(this, Document); text.Style = TextStyle; text.TextString = TextString; text.VerJustify = VdConstVerJust.VdTextVerCen; text.HorJustify = VdConstHorJust.VdTextHorCenter; text.Height = TextHeight; text.InsertionPoint = cen; vdPolyline pl = new vdPolyline(); entities.AddItem(cirStart); entities.AddItem(pl); //entities.AddItem(pl2); pl.MatchProperties(this, Document); cirStart.MatchProperties(this, Document); cirEnd.MatchProperties(this, Document); Vertexes verts = new Vertexes(); double stepangle = Globals.VD_TWOPI / this.NumSides; double sang = 0.0d; for (int i = 0; i < NumSides; i++) { verts.Add(gPoint.Polar(cen, sang, Radius)); sang += stepangle; } pl.VertexList = verts; pl.Flag = VdConstPlineFlag.PlFlagCLOSE; //entities.AddItem(cirEnd); cirStart.Center = cen; cirStart.Radius = mRadius; cirStart.Thickness = PipeHeight; //cirStart.Thickness = cirStart.Center.Distance3D(EndPoint); //cirStart.ExtrusionVector = new Vector(0.0, 1.0, 0.0); //cirStart.ExtrusionVector = Vector.CreateExtrusion(EndPoint, StartPoint); cirStart.ExtrusionVector = Vector.CreateExtrusion(StartPoint, EndPoint); cirEnd.Center = EndPoint; cirEnd.Radius = mRadius; //cirEnd.ExtrusionVector = Vector.CreateExtrusion(cen, EndPoint); //cirEnd.ExtrusionVector = cirStart.ExtrusionVector; // Draw DisNet Pipe gPoints gPts = GetDisNetPipePoints(); //vdPolyline plDisNet = new vdPolyline(); pl.VertexList = new Vertexes(gPts); //entities.AddItem(pl); }
public override void FillShapeEntities(ref vdEntities entities) { vdCircle circle = new vdCircle(); //entities.AddItem(circle); circle.MatchProperties(this, Document); circle.Radius = mRadius; circle.HatchProperties = mhatchprops; if (mShowLines) { gPoint cen = new gPoint(); vdLine line1; double dx = 0.0d, dy = 0.0d; dx = circle.Center.x - 0.5; dy = circle.Center.y; line1 = new vdLine(); line1.StartPoint = new gPoint(dx, dy, circle.Center.z); line1.EndPoint = new gPoint(circle.Center.x + 0.5d, circle.Center.y, circle.Center.z); line1.MatchProperties(this, Document); entities.AddItem(line1); for (int i = 0; i < 6; i++) { line1 = new vdLine(); line1.MatchProperties(this, Document); line1.StartPoint = new gPoint(dx, dy); line1.EndPoint = new gPoint(line1.StartPoint.x - 0.1d, line1.StartPoint.y - 0.3); dx += 0.2; //dy += 0.3; entities.AddItem(line1); } //line1 = new vdLine(); //line1.StartPoint = new gPoint(circle.Center.x - 1.0d, circle.Center.y, circle.Center.z); //line1.EndPoint = new gPoint(circle.Center.x + 1.0d, circle.Center.y, circle.Center.z); //line1.MatchProperties(this, Document); //entities.AddItem(line1); //line2 = new vdLine(); //line2.StartPoint = line1.StartPoint; //line2.EndPoint = new gPoint(line1.StartPoint.x-0.1d, line1.StartPoint.y - 0.5d); //line2.MatchProperties(this, Document); //entities.AddItem(line2); //line3 = new vdLine(); //line3.StartPoint = line1.EndPoint; //line3.EndPoint = new gPoint(line1.EndPoint.x - 0.1d, line1.EndPoint.y - 0.5d); //line3.MatchProperties(this, Document); //entities.AddItem(line3); //line4 = new vdLine(); //line4.StartPoint = new gPoint(line1.StartPoint.x + 0.3d, line1.StartPoint.y); //line4.EndPoint = new gPoint(line4.StartPoint.x - 0.1d, line4.EndPoint.y - 0.5d); //line4.MatchProperties(this, Document); //entities.AddItem(line4); //line5 = new vdLine(); //line5.StartPoint = new gPoint(line4.StartPoint.x + 0.3d, line4.StartPoint.y); //line5.EndPoint = new gPoint(line5.StartPoint.x - 0.1d, line5.EndPoint.y - 0.5d); //line5.MatchProperties(this, Document); //entities.AddItem(line5); //line6 = new vdLine(); //line6.StartPoint = new gPoint(line5.StartPoint.x + 0.3d, line5.StartPoint.y); //line6.EndPoint = new gPoint(line6.StartPoint.x - 0.1d, line6.EndPoint.y - 0.5d); //line6.MatchProperties(this, Document); //entities.AddItem(line6); //ASTRASupportPinned pinn = new ASTRASupportPinned(); //pinn.MatchProperties(this, Document); //pinn.Origin = circle.Center; //pinn.Radius = 0.2d; //entities.AddItem(pinn); } }
public override void FillShapeEntities(ref vdEntities entities) { //vdDocument document = entities.Document; //vdCircle circle = new vdCircle(); //entities.AddItem(circle); //circle.MatchProperties(this, Document); //circle.Radius = mRadius; //circle.HatchProperties = mhatchprops; //if (mShowLines) //{ // gPoint cen = new gPoint(); // vdLine line1; // double angle = 0.0; // for (int i = 0; i < 4; i++) // { // line1 = new vdLine(); // line1.MatchProperties(this, Document); // if (mhatchprops.FillMode == VdConstFill.VdFillModeNone) // { // line1.LineType = Document.LineTypes.Invisible; // } // line1.StartPoint = new gPoint(gPoint.Polar(cen, angle + mAngle, 3.0d * mRadius / 2.0d)); // line1.EndPoint = new gPoint(gPoint.Polar(cen, angle + mAngle, 2.0d * mRadius)); // angle += VectorDraw.Geometry.Globals.HALF_PI; // entities.AddItem(line1); // } //} gPoint EPT, SPT; SPT = StartPoint; EPT = EndPoint; vdLine line1 = new vdLine(); //line1.SetUnRegisterDocument(document); //line1.setDocumentDefaults(); line1.StartPoint = SPT; line1.EndPoint = EPT; entities.AddItem(line1); vdLine line2 = new vdLine(); //line2.SetUnRegisterDocument(document); //line2.setDocumentDefaults(); line2.StartPoint = new gPoint(SPT.x, SPT.y - 1, SPT.z); line2.EndPoint = new gPoint(EPT.x, EPT.y - 1, EPT.z); entities.AddItem(line2); ASTRAMemberLoad aline = new ASTRAMemberLoad(); entities.AddItem(aline); aline.InitializeProperties(); aline.setDocumentDefaults(); aline.StartPoint = line2.StartPoint; aline.EndPoint = line1.StartPoint; aline.arrowSize = 0.3; double ll = ((line1.Length() / 5.0d) / line1.Length()); double sx, sy, sz; double ex, ey, ez; sx = sy = sz = 0.0d; for (int j = 1; j <= 5; j++) { ASTRAMemberLoad aline1 = new ASTRAMemberLoad(); entities.AddItem(aline1); aline1.InitializeProperties(); aline1.setDocumentDefaults(); aline1.arrowSize = 0.3; sx = (j * ll) * (line2.EndPoint.x - line2.StartPoint.x) + line2.StartPoint.x; sy = (j * ll) * (line2.EndPoint.y - line2.StartPoint.y) + line2.StartPoint.y; sz = (j * ll) * (line2.EndPoint.z - line2.StartPoint.z) + line2.StartPoint.z; aline1.StartPoint = new gPoint(sx, sy, sz); ex = (j * ll) * (line1.EndPoint.x - line1.StartPoint.x) + line1.StartPoint.x; ey = (j * ll) * (line1.EndPoint.y - line1.StartPoint.y) + line1.StartPoint.y; ez = (j * ll) * (line1.EndPoint.z - line1.StartPoint.z) + line1.StartPoint.z; aline1.EndPoint = new gPoint(ex, ey, ez); } }