woonlwmi1n0.jpg
- using System;
- using System.Text;
- using System.Linq;
- using System.Xml;
- using System.Reflection;
- using System.ComponentModel;
- using System.Collections;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Windows;
- using System.Windows.Media.Imaging;
- using System.Windows.Forms;
- using System.Drawing;
- using System.IO;
- using Autodesk..ApplicationServices;
- using Autodesk.AutoCAD.DatabaseServices;
- using Autodesk.AutoCAD.Runtime;
- using Autodesk.AutoCAD.EditorInput;
- using Autodesk.AutoCAD.Geometry;
- using Autodesk.AutoCAD.Windows;
- using Autodesk.AutoCAD.GraphicsInterface;
- using MgdAcApplication = Autodesk.AutoCAD.ApplicationServices.Application;
- using MgdAcDocument = Autodesk.AutoCAD.ApplicationServices.Document;
- using AcWindowsNS = Autodesk.AutoCAD.Windows;
- using DotNetARX;
- namespace SageDesign
- {
- class DCBZJig:DrawJig
- {
- public AlignedDimension m_AlignedDimension;
- private Point3d m_dimLinePoint;
- public DCBZJig(AlignedDimension aliDim)
- {
- m_AlignedDimension = aliDim;
- }
- protected override bool WorldDraw(WorldDraw draw)
- {
- draw.Geometry.Draw(m_AlignedDimension);
- return true;
- }
- protected override SamplerStatus Sampler(JigPrompts prompts)
- {
- Editor ed = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor;
- Matrix3d mt = ed.CurrentUserCoordinateSystem;
- JigPromptPointOptions optJig = new JigPromptPointOptions
- ("\n请指定标注方向");
- PromptPointResult resJigDis = prompts.AcquirePoint(optJig);
- Point3d curPt = resJigDis.Value;
- if (resJigDis.Status == PromptStatus.Cancel)
- {
- return SamplerStatus.Cancel;
- }
- if (m_dimLinePoint != curPt)
- {
- Line l1 = new Line(this.m_AlignedDimension.XLine1Point,this.m_AlignedDimension.XLine2Point);
- Point3d tempDimLinePt2 = l1.GetClosestPointTo(curPt, true);
- Vector3d vect = new Vector3d(curPt.X - tempDimLinePt2.X, curPt.Y - tempDimLinePt2.Y, curPt.Z - tempDimLinePt2.Z);
- Point3d dimLinePt = tempDimLinePt2.Add(vect.GetNormal() * 500);
- // 保存当前点.
- m_dimLinePoint = dimLinePt;
- return SamplerStatus.OK;
- }
- else
- {
- return SamplerStatus.NoChange;
- }
- }
- [CommandMethod("DCBZ")]
- public void Dim()
- {
- Database db = HostApplicationServices.WorkingDatabase;
- Editor ed = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor;
- PromptPointOptions pPtOpts = new PromptPointOptions("\n点取要标注的第一点:");
- PromptPointResult pPtRes = ed.GetPoint(pPtOpts);
- Point3d xLine1Point = pPtRes.Value;
- if (pPtRes.Status == PromptStatus.OK)
- {
- pPtOpts.Message = "第二点";
- pPtOpts.BasePoint = xLine1Point;
- pPtOpts.UseBasePoint = true;
- pPtRes = ed.GetPoint(pPtOpts);
- if (pPtRes.Status == PromptStatus.OK)
- {
- Point3d xLine2Point = pPtRes.Value;
- AlignedDimension aliDim = new AlignedDimension(xLine1Point,xLine2Point,xLine1Point,"",db.Dimstyle);
- DCBZJig dcbzjig = new DCBZJig(aliDim);
- PromptResult resJig = ed.Drag(dcbzjig);
- if (resJig.Status == PromptStatus.OK)
- {
- Tools.AddToModelSpace(db,dcbzjig.m_AlignedDimension);
- }
- }
- }
- }
- }
- }
|