// Zoom via COM private static void ZoomWin2( _AcEd.Editor ed, _AcGe.Point3d min, _AcGe.Point3d max ) { _AcInt.AcadApplication app = (_AcInt.AcadApplication)_AcAp.Application.AcadApplication; double[] lower = new double[3] { min.X, min.Y, min.Z }; double[] upper = new double[3] { max.X, max.Y, max.Z }; app.ZoomWindow(lower, upper); }
} // for sorting public _Area_v2(_Db.ObjectId id, _Ge.Point3d s, _Ge.Point3d e) { _id = id; _start = s; _end = e; }
/// <summary> /// Створює елементи вектору з данними виносу. /// </summary> private void CreateDrawingStakeOut() { if (this.PointStation == null) { return; } AcGe.Point3d pntStart = new AcGe.Point3d(this.PointStation.E, this.PointStation.N, this.PointStation.H); AcGe.Point3d pntEnd = new AcGe.Point3d(this.Coordinates.X, this.Coordinates.Y, 0); AcDb.Line line = new AcDb.Line(pntStart, pntEnd); line.Visible = this.Visible; AcGe.Point3d pntMiddle = new AcGe.LineSegment3d(pntStart, pntEnd).MidPoint; double angleTXT = line.Angle; if (angleTXT > Math.PI / 2 && angleTXT < Math.PI * 3 / 2) { angleTXT += Math.PI; } AcDb.MText text = new AcDb.MText(); text.Contents = this.DistanceToString(AcRx.DistanceUnitFormat.Decimal) + "\r\n" + "л.к. " + ServiceTable.FormatAngleValue(this.LeftlAngleToString(AcRx.AngularUnitFormat.DegreesMinutesSeconds)); text.Rotation = angleTXT; text.Location = pntMiddle; text.Attachment = AcDb.AttachmentPoint.MiddleCenter; text.Width = 25; text.TextHeight = 1.8 * this.ScaleDrawing; this.lineID = ServiceCAD.InsertObject(line); this.txtID = ServiceCAD.InsertObject(text); }
public static bool InPoly(_AcGe.Point3d vertexPoint, _AcDb.Entity pElFG) { int nrTrue = 0; int nrFalse = 0; if (InPoly(vertexPoint, 1.0, 1.0, pElFG)) { nrTrue++; } else { nrFalse++; } if (InPoly(vertexPoint, -1.0, 1.0, pElFG)) { nrTrue++; } else { nrFalse++; } if (InPoly(vertexPoint, -1.0, -1.0, pElFG)) { nrTrue++; } else { nrFalse++; } return(nrTrue > nrFalse); }
private bool insertFormSide(_Ge.Point3d ptPos, double dir, double rotation) { _Ed.PromptStringOptions pStrOpts = new _Ed.PromptStringOptions("\nFormSide: "); pStrOpts.AllowSpaces = false; _Ed.PromptResult pStrRes = _c.ed.GetString(pStrOpts); string result = pStrRes.StringResult; if (pStrRes.Status == _Ed.PromptStatus.Cancel) { return(false); } _Ge.Point3d insert = ptPos; _Db.AttachmentPoint a = _Db.AttachmentPoint.BottomCenter; if (rotation == 0.0) { a = _Db.AttachmentPoint.BottomCenter; double newX = ptPos.X - (bigCircleOffset - bigCircleRadius) * dir / 2; double newY = ptPos.Y + textOffset; insert = new _Ge.Point3d(newX, newY, ptPos.Z); } else { a = _Db.AttachmentPoint.MiddleRight; double newX = ptPos.X - textOffset; double newY = ptPos.Y - (bigCircleOffset - bigCircleRadius) * dir / 2; insert = new _Ge.Point3d(newX, newY, ptPos.Z); } insertText(insert, a, result, 0); return(true); }
protected override AcEd.SamplerStatus Sampler(AcEd.JigPrompts prompts) { AcEd.JigPromptPointOptions jppo = new AcEd.JigPromptPointOptions(); AcEd.PromptPointResult ppr; jppo.Message = this.methodConstructing.GetMessage(); jppo.UseBasePoint = false; ppr = prompts.AcquirePoint(jppo); if (ppr.Status == AcEd.PromptStatus.Cancel || ppr.Status == AcEd.PromptStatus.Error) { return(AcEd.SamplerStatus.Cancel); } AcGe.Point3d tmpPt = ppr.Value.TransformBy(UCS.Inverse()); if (!this.diagonalPoint.IsEqualTo(tmpPt, new AcGe.Tolerance(10e-10, 10e-10))) { this.diagonalPoint = tmpPt; return(AcEd.SamplerStatus.OK); } else { return(AcEd.SamplerStatus.NoChange); } }
private void insertLine(_Ge.Point3d ptPos, double dir, double rotation) { _Db.BlockTableRecord btr = _c.trans.GetObject(_c.modelSpace.Id, _Db.OpenMode.ForWrite) as _Db.BlockTableRecord; _Ge.Point3d ptEnd = new _Ge.Point3d(); if (rotation == 0.0) { double newX = ptPos.X - (bigCircleOffset - bigCircleRadius) * dir; double newY = ptPos.Y; ptEnd = new _Ge.Point3d(newX, newY, ptPos.Z); } else { double newX = ptPos.X; double newY = ptPos.Y - (bigCircleOffset - bigCircleRadius) * dir; ptEnd = new _Ge.Point3d(newX, newY, ptPos.Z); } using (_Db.Line line = new _Db.Line(ptPos, ptEnd)) { btr.AppendEntity(line); _c.trans.AddNewlyCreatedDBObject(line, true); } }
private bool getPoint(string prompt, _Ge.Point3d ptBase, ref _Ge.Point3d pt, ref bool finish) { _Ed.PromptPointOptions pPtOpts = new _Ed.PromptPointOptions(""); pPtOpts.Keywords.Add("F"); pPtOpts.Message = prompt; pPtOpts.UseBasePoint = true; pPtOpts.BasePoint = ptBase; _Ed.PromptPointResult pPtRes; pPtRes = _c.ed.GetPoint(pPtOpts); if (pPtRes.Status == _Ed.PromptStatus.Keyword) { _Ed.PromptPointOptions lastPtOpts = new _Ed.PromptPointOptions(""); pPtOpts.Message = "Last Point"; pPtOpts.UseBasePoint = true; pPtOpts.BasePoint = ptBase; pPtRes = _c.ed.GetPoint(lastPtOpts); pt = pPtRes.Value; finish = true; } else if (pPtRes.Status == _Ed.PromptStatus.OK) { pt = pPtRes.Value; } else if (pPtRes.Status == _Ed.PromptStatus.Cancel) { return(false); } return(true); }
private void mainCreationLoop(List <_Area_v2> areas) { foreach (_Area_v2 area in areas) { string name = getAreaName(area); double scale = getAreaScale(area); _Ge.Point3d centerPoint = getAreaCenter(area); _Db.Layout lay = createLayoutandSetActive(name); //setLayoutPlotSettings(lay, "ISO_full_bleed_A3_(297.00_x_420.00_MM)", "monochrome.ctb", "DWG To PDF.pc3"); setLayoutPlotSettings(lay, "PDFCreator", "A3", "monochrome.ctb"); _Db.Viewport vp = layoutViewportGetter(lay); _Db.Extents2d ext = getMaximumExtents(lay); setViewportGeometry(vp, ext, 1.05); setViewportParameters(vp, scale, centerPoint); Dictionary <_Db.Layout, string> layouts = new Dictionary <_Db.Layout, string>(); layouts[lay] = name; plotDriver(layouts); removeLayout(lay); } _c.ed.Regen(); }
// Database extensions ///<summary> /// Create a piece of text of a specified size at a specified location. ///</summary> ///<param name="norm">The normal to the text object.</param> ///<param name="pt">The position for the text.</param> ///<param name="conts">The contents of the text.</param> ///<param name="size">The size of the text.</param> public static void CreateText( this _AcDb.Database db, _AcGe.Vector3d norm, _AcGe.Point3d pt, string conts, double size ) { using (var tr = db.TransactionManager.StartTransaction()) { var ms = tr.GetObject( _AcDb.SymbolUtilityServices.GetBlockModelSpaceId(db), _AcDb.OpenMode.ForWrite ) as _AcDb.BlockTableRecord; if (ms != null) { var txt = new _AcDb.DBText(); txt.Normal = norm; txt.Position = pt; txt.Justify = _AcDb.AttachmentPoint.MiddleCenter; txt.AlignmentPoint = pt; txt.TextString = conts; txt.Height = size; var id = ms.AppendEntity(txt); tr.AddNewlyCreatedDBObject(txt, true); } tr.Commit(); } }
internal void run() { List <_Db.BlockReference> viiteBlocks = getAllBlocks(blockNames); if (viiteBlocks.Count == 0) { string names = string.Join(", ", blockNames.ToArray()); throw new DMTException("[ERROR] - (" + names + ") - not found"); } List <Viide> viited = getData(viiteBlocks); List <_Db.BlockReference> areas = getAllBlocks(areaName); if (areas.Count < 1) { _Ge.Point3d ip = getPoint(); output(viited, ip); } else { Dictionary <_Db.BlockReference, List <Viide> > data = matchBlockToArea(areas, viited); foreach (_Db.BlockReference area in areas) { output(data[area], area.GeometricExtents.MaxPoint); } } }
private void insertReinforcmentMark(string mark, G.Point IP) { string layerName = "K023TL"; string styleName = "dmt_M" + (int)Math.Round(L._V_.Z_DRAWING_SCALE); textStyleHandler(); blockHandler(); leaderStyleHandler(styleName, (int)Math.Round(L._V_.Z_DRAWING_SCALE)); _Db.DBDictionary mleaderStyleTable = _c.trans.GetObject(_c.db.MLeaderStyleDictionaryId, _Db.OpenMode.ForWrite) as _Db.DBDictionary; _Ge.Point3d insertPointLeader = new _Ge.Point3d(IP.X, IP.Y, 0); _Ge.Point3d insertPointText = new _Ge.Point3d(IP.X + 7.5 * L._V_.Z_DRAWING_SCALE, IP.Y + 7.5 * L._V_.Z_DRAWING_SCALE, 0); _Db.MText mText = new _Db.MText(); mText.SetDatabaseDefaults(); mText.Contents = mark; _Db.MLeader leader = new _Db.MLeader(); leader.SetDatabaseDefaults(); leader.ContentType = _Db.ContentType.MTextContent; leader.MText = mText; leader.AddLeaderLine(insertPointLeader); leader.TextLocation = insertPointText; leader.MLeaderStyle = mleaderStyleTable.GetAt(styleName); leader.Layer = layerName; _c.modelSpace.AppendEntity(leader); _c.trans.AddNewlyCreatedDBObject(leader, true); }
public BeamData(double height, double width, double maxlength, _AcGe.Point3d p0, _AcGe.Point3d p1, _AcGe.Point3d pSide = new _AcGe.Point3d()) { BeamStartPoint = p0; BeamEndPoint = p1; BeamSidePoint = pSide; Height = height; Width = width; Length = BeamStartPoint.GetVectorTo(BeamEndPoint).Length; MaxLength = maxlength; if (Length > MaxLength) { MessageBox.Show("WARNING! - picked beam length is greater than maximum length for selected beam type."); } // // We need to check the incoming pSide var to see if we need to offset our beam to one side // or draw it on the centre line (the picked points form the centre line). // if (pSide.GetAsVector().Length == 0) { OffsetFactor = 0.5; // no offset so set offset factor to half width to draw on centre line } else { OffsetFactor = 1.0; // full offset required } }
// Helper functions to zoom using different techniques // Zoom using a view object private static void ZoomWin( _AcEd.Editor ed, _AcGe.Point3d min, _AcGe.Point3d max ) { _AcGe.Point2d min2d = new _AcGe.Point2d(min.X, min.Y); _AcGe.Point2d max2d = new _AcGe.Point2d(max.X, max.Y); _AcDb.ViewTableRecord view = new _AcDb.ViewTableRecord(); view.CenterPoint = min2d + ((max2d - min2d) / 2.0); view.Height = max2d.Y - min2d.Y; view.Width = max2d.X - min2d.X; ed.SetCurrentView(view); }
protected override AcEd.SamplerStatus Sampler(AcEd.JigPrompts jp) { AcEd.JigPromptPointOptions po = new AcEd.JigPromptPointOptions("\nВкажіть точку вставки:"); po.UserInputControls = (AcEd.UserInputControls.Accept3dCoordinates | AcEd.UserInputControls.NullResponseAccepted | AcEd.UserInputControls.NoNegativeResponseAccepted | AcEd.UserInputControls.GovernedByOrthoMode); AcEd.PromptPointResult ppr = jp.AcquirePoint(po); if (ppr.Status == AcEd.PromptStatus.Keyword) { return(AcEd.SamplerStatus.NoChange); } else if (ppr.Status == AcEd.PromptStatus.OK) { if (_location.DistanceTo(ppr.Value) < AcGe.Tolerance.Global.EqualPoint) { return(AcEd.SamplerStatus.NoChange); } _location = ppr.Value; return(AcEd.SamplerStatus.OK); } return(AcEd.SamplerStatus.Cancel); }
ArraysBlocks() { this.NameBlock = ""; this.ScaleBlock = 1; this.RotationBlock = 0; this.BasePointArrays = AcGe.Point3d.Origin; }
private void createX(_Db.BlockTableRecord btr, double radius, _Ge.Point3d ip) { _Ge.Point2d p1 = new _Ge.Point2d(ip.X - radius, ip.Y); _Ge.Point2d p2 = new _Ge.Point2d(ip.X + radius, ip.Y); _Ge.Point2d p3 = new _Ge.Point2d(ip.X, ip.Y - radius); _Ge.Point2d p4 = new _Ge.Point2d(ip.X, ip.Y + radius); using (_Db.Polyline poly = new _Db.Polyline()) { poly.AddVertexAt(0, p1, 0, 0, 0); poly.AddVertexAt(1, p2, 0, 0, 0); poly.ColorIndex = 2; btr.AppendEntity(poly); _c.trans.AddNewlyCreatedDBObject(poly, true); } using (_Db.Polyline poly = new _Db.Polyline()) { poly.AddVertexAt(0, p3, 0, 0, 0); poly.AddVertexAt(1, p4, 0, 0, 0); poly.ColorIndex = 2; btr.AppendEntity(poly); _c.trans.AddNewlyCreatedDBObject(poly, true); } }
private void createBlock(_Ge.Point3d center) { if (!_c.blockTable.Has(blockName)) { write("Create missing block"); _Db.BlockTableRecord btr = new _Db.BlockTableRecord(); btr.Name = blockName; _Db.ObjectId btrId = _c.blockTable.Add(btr); _c.trans.AddNewlyCreatedDBObject(btr, true); createX(btr, 1.5, new _Ge.Point3d(0, 0, 0)); createCircle(btr, 1, new _Ge.Point3d(0, 0, 0)); _Db.BlockReference newBlockReference = new _Db.BlockReference(center, btrId); newBlockReference.TransformBy(_Ge.Matrix3d.Scaling(40, center)); _c.modelSpace.AppendEntity(newBlockReference); _c.trans.AddNewlyCreatedDBObject(newBlockReference, true); } else { using (_Db.BlockReference newBlockReference = new _Db.BlockReference(center, _c.blockTable[blockName])) { newBlockReference.TransformBy(_Ge.Matrix3d.Scaling(40, center)); _c.modelSpace.AppendEntity(newBlockReference); _c.trans.AddNewlyCreatedDBObject(newBlockReference, true); } } }
private void outputTable(_Area_v2 a, List <_Mark> rows) { _Db.DBObject currentEntity = _c.trans.GetObject(a.ID, _Db.OpenMode.ForWrite, false) as _Db.DBObject; if (currentEntity is _Db.BlockReference) { _Db.BlockReference blockRef = currentEntity as _Db.BlockReference; double scale = blockRef.ScaleFactors.X; string name = blockRef.Name; _Ge.Point3d currentPoint = a.Start; if (name == newBoxNames[0]) { currentPoint = new _Ge.Point3d(a.Start.X + (366 * scale), a.Start.Y + (141.8 * scale), a.Start.Z); } else if (name == newBoxNames[1]) { currentPoint = new _Ge.Point3d(a.Start.X + (366 * scale), a.Start.Y + (263.5 * scale), a.Start.Z); } int counter = 0; foreach (_Mark r in rows) { if (r.Position != "emptyrow") { double txtHeight = 1.5 * scale; _Ge.Point3d position_IP = new _Ge.Point3d(currentPoint.X + (1 * scale), currentPoint.Y + (1.125 * scale), currentPoint.Z); _Ge.Point3d diameter_IP = new _Ge.Point3d(currentPoint.X + (0.75 * scale) + (6.1 * scale), currentPoint.Y + (1.125 * scale), currentPoint.Z); _Ge.Point3d number_IP = new _Ge.Point3d(currentPoint.X + (1.5 * scale) + (9.75 * scale), currentPoint.Y + (1.125 * scale), currentPoint.Z); insertText(r.Position, position_IP, _Mark.markLayerName, txtHeight); insertText(r.Diameter.ToString(), diameter_IP, _Mark.markLayerName, txtHeight); insertText(r.Number.ToString(), number_IP, _Mark.markLayerName, txtHeight); } if (counter == 19) { if (name == newBoxNames[0]) { currentPoint = new _Ge.Point3d(a.Start.X + (336 * scale), a.Start.Y + (141.8 * scale), a.Start.Z); } else if (name == newBoxNames[1]) { currentPoint = new _Ge.Point3d(a.Start.X + (336 * scale), a.Start.Y + (263.5 * scale), a.Start.Z); } } else { currentPoint = new _Ge.Point3d(currentPoint.X, currentPoint.Y - (4 * scale), currentPoint.Z); } counter++; } } }
public static double GetProjectionOnLine(AcGe.Point3d startPointLine, AcGe.Point3d endPointLine, AcGe.Point3d point) { double dirAngleLine = GetDirAngle(startPointLine, endPointLine); double dirAngleToPoint = GetDirAngle(startPointLine, point); double a = dirAngleToPoint - dirAngleLine; return(Math.Cos(a) * startPointLine.GetVectorTo(point).Convert2d(new AcGe.Plane()).Length); }
private _Ge.Point3d getCenter(_Db.Region reg) { _Db.Solid3d solid = new _Db.Solid3d(); solid.Extrude(reg, 2.0, 0.0); _Ge.Point3d solidCentroid = solid.MassProperties.Centroid; return(new _Ge.Point3d(solidCentroid.X, solidCentroid.Y, 0)); }
public CoordinatesRecordSDR(string namePoint, AcGe.Point3d point, string description) { this.NamePoint = namePoint; this.Northing = point.Y.ToString("0.000").Replace(",", "."); this.Easting = point.X.ToString("0.000").Replace(",", "."); this.Elevation = point.Z.ToString("0.000").Replace(",", "."); this.Description = description; }
public _Area_v1(_Ge.Point3d s, _Ge.Point3d e) { start = s; end = e; reinf = new _Ge.Point3d(e.X - 2180, e.Y - 1460, e.Z); weight = new _Ge.Point3d(e.X - 780, e.Y - 5062, e.Z); }
public static AcDb.ObjectId InsertBlock( String nameBlock, AcGe.Point3d insertionPoint, double scale, double rotation) { return(InsertBlock(nameBlock, insertionPoint, scale, rotation, AcDb.ObjectId.Null, null)); }
// Returns whether the provided DB extents - retrieved from // Database.Extmin/max - are "valid" or whether they are the default // invalid values (where the min's coordinates are positive and the // max coordinates are negative) private bool ValidDbExtents(_AcGe.Point3d min, _AcGe.Point3d max) { return (!(min.X > 0 && min.Y > 0 && min.Z > 0 && max.X < 0 && max.Y < 0 && max.Z < 0)); }
private void logic() { List <_Db.Dimension> wrongDims = new List <_Db.Dimension>(); Dictionary <_Ge.Point3d, _Db.Dimension> wrongPoints = new Dictionary <_Ge.Point3d, _Db.Dimension>(); foreach (_Db.Dimension dim in dims.Keys) { _Db.BlockTableRecord btr = dims[dim]; List <_Ge.Point3d> points = getBlockTableRecordPoints(btr); if (dim is _Db.RotatedDimension) { _Db.RotatedDimension rdim = dim as _Db.RotatedDimension; _Ge.Point3d p1 = rdim.XLine1Point; _Ge.Point3d p2 = rdim.XLine2Point; bool pp1 = matchPoints(p1, points); bool pp2 = matchPoints(p2, points); if (pp1 == false) { wrongPoints[p1] = dim; if (!wrongDims.Contains(dim)) { wrongDims.Add(dim); } } if (pp2 == false) { wrongPoints[p2] = dim; if (!wrongDims.Contains(dim)) { wrongDims.Add(dim); } } } } write("Vigade arv: " + wrongDims.Count().ToString()); if (wrongDims.Count > 0) { initLayer(kontrollLayer); } foreach (_Db.Dimension dim in wrongDims) { changeFillColor(dim, 1); } foreach (_Ge.Point3d pt in wrongPoints.Keys) { _Db.Dimension dim = wrongPoints[pt]; createCircle(100, 1, pt, dims[dim]); createCircle(750, 1, pt, dims[dim]); } }
public SettingTable() { this.KeyTable = "NoKey"; this.TypeTable = Tables.TypeTable.TableBorderParcel; this.title = "None"; this.TextHeight = 2; this.Columns = new List <ColumnTable>(); this.BasePointDrawing = AcGe.Point3d.Origin; }
public static AcDb.ObjectId InsertBlock( string nameBlock, AcGe.Point3d insertionPoint, double scale, double rotation, Dictionary <string, string> tags) { return(InsertBlock(nameBlock, insertionPoint, scale, rotation, AcDb.ObjectId.Null, tags)); }
public static AcDb.DBText CreateText(AcGe.Point3d insertPoint, string textValue) { AcDb.DBText text = new AcDb.DBText { TextString = textValue, Position = insertPoint }; return(text); }
ArraysBlocks(string nameBlock, double scaleBlock, double rotationBlock, AcGe.Point3d basePointArrays) { this.NameBlock = nameBlock; this.ScaleBlock = scaleBlock; this.RotationBlock = rotationBlock; this.BasePointArrays = BasePointArrays; }