- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Friends,
Can any of you help me with the code below?
I can insert a bracket of 51 mm x 6.3 mm horizontally.
If I try to enter angle values are not correct.
How can I leave the values prevail even with angle?
Hugs,
Josano
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using AcDb = Autodesk.AutoCAD.DatabaseServices.TransactionManager;
namespace ClassLibrary9
{
public class Class1
{
[CommandMethod("ssa")]
public static void GetPointsFromUser()
{
// le o banco de dados corrente e inicia o gerenciador de transações
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
PromptPointResult pPtRes;
PromptPointOptions pPtOpts = new PromptPointOptions("");
// Mensagem para ponto inicial
pPtOpts.Message = "\nSelecione o ponto inicial da linha: ";
pPtRes = acDoc.Editor.GetPoint(pPtOpts);
Point3d ptStart = pPtRes.Value;
// Se o usuario pressionar esc ou cancelar o comando sai
if (pPtRes.Status == PromptStatus.Cancel) return;
// Mensagem para ponto final
pPtOpts.Message = "\nSelecione o ponto final da linha: ";
pPtOpts.UseBasePoint = true;
pPtOpts.BasePoint = ptStart;
pPtRes = acDoc.Editor.GetPoint(pPtOpts);
Point3d ptEnd = pPtRes.Value;
if (pPtRes.Status == PromptStatus.Cancel) return;
// Inicia a transação
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
BlockTable acBlkTbl;
BlockTableRecord acBlkTblRec;
// Abre o model space para escrever
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
OpenMode.ForRead) as BlockTable;
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
OpenMode.ForWrite) as BlockTableRecord;
Line acline1 = new Line(ptStart, ptEnd);
Line acline2 = new Line(ptStart, ptEnd);
Line acline3 = new Line(ptStart, ptEnd);
acline2.StartPoint = new Point3d(acline2.StartPoint.X , acline2.StartPoint.Y - 44.7, 0);
acline2.EndPoint = new Point3d(acline2.EndPoint.X , acline2.EndPoint.Y - 44.7, 0);
acline3.StartPoint = new Point3d(acline3.StartPoint.X , acline3.StartPoint.Y - 51, 0);
acline3.EndPoint = new Point3d(acline3.EndPoint.X , acline3.EndPoint.Y - 51, 0);
acline1.SetDatabaseDefaults();
acline2.SetDatabaseDefaults();
acline3.SetDatabaseDefaults();
// Adicionar as linhas ao desenho
acBlkTblRec.AppendEntity(acline1);
acBlkTblRec.AppendEntity(acline2);
acBlkTblRec.AppendEntity(acline3);
acTrans.AddNewlyCreatedDBObject(acline1, true);
acTrans.AddNewlyCreatedDBObject(acline2, true);
acTrans.AddNewlyCreatedDBObject(acline3, true);
// Confirma as alterações
acTrans.Commit();
}
}
}
}
Solved! Go to Solution.