Beruflich Dokumente
Kultur Dokumente
2 Passo: Coloque o nome que for conveniente, e depois clique em Class Library, como mostra a figura a seguir. Depois clique em OK
Os arquivos acdbmgd e acmgd vamos achar na aba Brawse Arquivos de programa >> AutoCAD2007 Os arquivos acdbmgd e acmgd devemos coloca-los como Copy local igual a False veja a seguir.
As DLLs do AutoCAD para projetos .NET so: acmgd.dll >> Acesso ao runtime acdbmgd.dll >> Acesso as entidades de banco de dados Se voc for em referencia ver o seguinte:
Para salvar o programa com outro nome em outro diretrio, faa o seguinte File >> Save As >> crie um novo diretrio e d um novo nome. Entre em propriedades >> na aba Compile* >> Brouse... >> localize onde esta a pasta gravada.
Abra o autocad 2007 e veja o resultado. Digite netload, vai abrir uma janela e localize o arquivo com a estenso.dll gerada pelo aplicativo Acima. E veja o resultado a seguir.
uma boa prtica para adicion-lo ao topo de cada arquivo no seu projeto uma vez que ir reduzir o nmero de erros mais tarde:
''sempre colocar isso no inicio Imports Autodesk.AutoCAD.Geometry Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.EditorInput Imports Autodesk.AutoCAD.Interop Imports Autodesk.AutoCAD.Interop.Common ''point3d ''pra pegar o modelspace ''commandmethod ''editor, propmptpointoptions
Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx PARA USAR COMANDOS DO VBA EM VB.NET PRECISO USAR Imports Autodesk.AutoCAD.Interop Imports Autodesk.AutoCAD.Interop.Common Public ReadOnly Property ThisDrawing() As AcadDocument Get Return Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocu ment.AcadDocument End Get End Property xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ' comando a ser digitado "ola" <Autodesk.AutoCAD.Runtime.CommandMethod("ola")> _ OS Imports
Public Sub Myroutyne() ' escreve no Prompt ThisDrawing.Utility.Prompt("OL Marcio estou s comeando!!!") ' escreve na caixa de mensagem MsgBox(" OK !!!") xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ''PEDIR O PONTO DE INSERCAO Dim PPO As New PromptPointOptions(" Clique em um ponto de Insero") Dim PPR As PromptPointResult = ED.GetPoint(PPO)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ''MOSTRA O FORM COM NOME DOS BLOCOS 'formi a variavel 'Fintroduzir o nome do formulario Dim formi As New Fintroduzir If formi.ShowDialog <> Windows.Forms.DialogResult.OK Then Exit Sub
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx MENSSAGENS MsgBox("BLOCO NAO ENCONTRADO!") xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx COORDENADAS Dim pt As Point3d = ppr.Value pt = New Point3d(pt.X, pt.Y - 3, 0) xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx COR NO AUTOCAD N COR DESCRIO 1 VERMELHA 2 AMARELA 3 VERDE 4 CIAN 5 AZUL 6 MAGENTA 7 BRANCA 8 CINZA ESCURO 9 CINZA CLARO E ASSIM AT O N 255 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Tudo o que resta agora adicionar uma funo que vai chamar a nossa funo AddLine para criar uma linha em nosso desenho ativo.
<CommandMethod( "AddLine" )> _ Pblico AddLineToModelSpace Sub () Experimente 'Definir o nosso primeiro ponto 0,0,0 Dim opt1 como nova Point3D (0, 0, 0) 'Definir o nosso segundo ponto de 5,5,0 Dim OPT2 como nova Point3D (5, 5, 0)
'Chamar a funo AddLine, passando os nossos dois pontos definidos Se no AddLine (opt1, OPT2) Ento Throw New System.Exception ("Erro ao chamar AddLine.") Catch ex As System.Exception MsgBox (ex.Message, MsgBoxStyle.Information, "Erro na WoPrj") End Try End Sub
End Sub End Class End Namespace Dim sob As SweepOptionsBuilder = SweepOptionsBuilder ' Align the entity to sweep to the path / / Alinhar a entidade para varrer para o caminho sob.Align = SweepOptionsAlignOption.AlignSweepEntityToPath Dim AlignSweepEntityToPath.; As SweepOptionsAlignOption sob.BasePoint = pathEnt.StartPoint ' The profile will rotate to follow the path / / O perfil vai rodar a seguir o caminho sob.Bank = true sob.Bank = true ss.CreateSweptSurface(ss.CreateSweptSurface(sweepEnt, sweepEnt, pathEnt, pathEnt, sob.ToSweepOp tions, sob.ToSweepOptions)) UnknownUnknownUnknownms.AppendEntity(ss) ms.AppendEntity(ss) tr.AddNewlyCreatedDBObject(ss, true) tr.AddNewlyCreatedDBObject(ss, true) tr.Commit tr.Commit UnknownUnknowncatchcapturas {Unknown{UnknownUnknownUnknownUnknownUnknownUnknownUnknownUnknownUnknown Private sob.BasePoint As pathEnt.StartPoint ' Now generate the surface... / / Agora gerar a superfcie ... Private ss As SweptSurface Private bt As BlockTable = bt Private ms As BlockTableRecord Private Function SweepOptionsBuilder() As nova End Function Private Function SweptSurface() As nova End Function xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Criao de uma tabela de AutoCAD que contm imagens de bloco usando. NET
Aqui est a actualizao C # cdigo:
using using using using using
Autodesk.AutoCAD.ApplicationServices; usando Autodesk.AutoCAD.ApplicationServices; Autodesk.AutoCAD.DatabaseServices; usando Autodesk.AutoCAD.DatabaseServices; Autodesk.AutoCAD.EditorInput; usando Autodesk.AutoCAD.EditorInput; Autodesk.AutoCAD.Geometry; usando Autodesk.AutoCAD.Geometry; Autodesk.AutoCAD.Runtime; usando Autodesk.AutoCAD.Runtime;
namespace TableCreation TableCreation namespace { { public class Commands Comandos pblico de classe { { [ CommandMethod ( "CRT" )] [CommandMethod ("CRT")] static public void CreateTable() CreateTable public static void () { { Document doc = Document doc = Application .DocumentManager.MdiActiveDocument; Aplicao DocumentManager.MdiActiveDocument.; Database db = doc.Database; db = Database doc.Database; Editor ed = doc.Editor; Editor doc.Editor = ed; PromptPointResult pr = pr PromptPointResult = ed.GetPoint( "\nEnter table insertion point: " ); ed.GetPoint ("tabela do ponto de insero \ nDigite:"); if (pr.Status == PromptStatus .OK) if (pr.Status PromptStatus ==. OK) { { Transaction tr = Transaction tr = doc.TransactionManager.StartTransaction(); doc.TransactionManager.StartTransaction (); using (tr) using (tr) { { BlockTable bt = bt BlockTable =
( BlockTable )tr.GetObject( (BlockTable) tr.GetObject ( doc.Database.BlockTableId, doc.Database.BlockTableId, OpenMode .ForRead OpenMode. ForRead ); ); Table tb = new Table (); tb nova tabela tabela = (); tb.TableStyle = db.Tablestyle; db.Tablestyle tb.TableStyle =; tb.NumRows = 5; tb.NumRows = 5; // Added an additional column for the block image / / Adicionado uma coluna adicional para a imagem do bloco tb.NumColumns = 4; tb.NumColumns = 4; tb.SetRowHeight(3); tb.SetRowHeight (3); tb.SetColumnWidth(15); tb.SetColumnWidth (15); tb.Position = pr.Value; tb.Position = pr.Value; // Create a 2-dimensional array / / Cria um array de 2 dimenses // of our table contents / / Da tabela de contedo de nossa string [,] str = new string [5, 3]; String [], str = new String [5, 3]; str[0, 0] = "Part No." ; str [0, 0] = "Pea n "; str[0, 1] = "Name " ; str [0, 1] = "Nome"; str[0, 2] = "Material " ; str [0, 2] = "Material"; str[1, 0] = "1876-1" ; str [1, 0] = "1876-1"; str[1, 1] = "Flange" ; str [1, 1] = "flange"; str[1, 2] = "Perspex" ; str [1, 2] = "perspex"; str[2, 0] = "0985-4" ; str [2, 0] = "0985-4"; str[2, 1] = "Bolt" ; str [2, 1] = "Bolt"; str[2, 2] = "Steel" ; str [2, 2] = "Ao"; str[3, 0] = "3476-K" ; str [3, 0] = "K-3476"; str[3, 1] = "Tile" ; str [3, 1] = "telha"; str[3, 2] = "Ceramic" ; str [3, 2] = "Cermica"; str[4, 0] = "8734-3" ; str [4, 0] = "8734-3"; str[4, 1] = "Kean" ; str [4, 1] = "Kean"; str[4, 2] = "Mostly water" ; str [4, 2] = "Na maior parte da gua"; // Use a nested loop to add and format each cell / / Uso um loop aninhado para adicionar e formatar cada clula for ( int i = 0; i < 5; i++) for (int i = 0; i <5; i + +) { { for ( int j = 0; j < 3; j++) for (int j = 0; j <3; j + +) { { tb.SetTextHeight(i, j, 1); tb.SetTextHeight (i, j, 1); tb.SetTextString(i, j, str[i, j]); tb.SetTextString (i, j, str [i, j]); tb.SetAlignment(i, j, CellAlignment .MiddleCenter); tb.SetAlignment (i, j, CellAlignment MiddleCenter.); } } // If a block definition exists for a block of our / / Se existe uma definio de bloco de um bloco de nossas // "name" field, then let's set it in the 4th column / / Campo "Nome", ento vamos configur-lo na coluna 4 if (bt.Has(str[i, 1])) if (bt.Has (str [i, 1])) { { tb.SetBlockTableRecordId(i, 3, bt[str[i, 1]], true ); tb.SetBlockTableRecordId (i, 3, bt [str [i, 1]], true); } } } } tb.GenerateLayout(); tb.GenerateLayout (); BlockTableRecord btr = BlockTableRecord BTR = ( BlockTableRecord )tr.GetObject( (BlockTableRecord) tr.GetObject ( bt[ BlockTableRecord .ModelSpace], bt [BlockTableRecord. ModelSpace] OpenMode .ForWrite OpenMode. ForWrite ); ); btr.AppendEntity(tb); btr.AppendEntity (tb); tr.AddNewlyCreatedDBObject(tb, true ); tr.AddNewlyCreatedDBObject (tb, true); tr.Commit(); tr.Commit (); } } } } } } } } } }
And here's what you see if you run the CRT command with some blocks in the current drawing called "FLANGE", "TILE", "BOLT" and "KEAN": E aqui est o que voc v se voc executar o comando CRT com alguns blocos no desenho atual chamado "flange", "Mosaico", "Bolt" e "Kean":
<Autodesk.AutoCAD.Runtime.CommandMethod("CalArea")> _
Public Sub CalculateDefinedArea() '' Prompt the user for 5 points Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument Dim pPtRes As PromptPointResult Dim colPt As Point2dCollection = New Point2dCollection Dim pPtOpts As PromptPointOptions = New PromptPointOptions("") '' Prompt for the first point pPtOpts.Message = vbLf & "Clique no primeiro ponto: " pPtRes = acDoc.Editor.GetPoint(pPtOpts) colPt.Add(New Point2d(pPtRes.Value.X, pPtRes.Value.Y)) '' Exit if the user presses ESC or cancels the command If pPtRes.Status = PromptStatus.Cancel Then Exit Sub Dim nCounter As Integer = 1 While (nCounter <= 4) '' Prompt for the next points Select Case nCounter Case 1 pPtOpts.Message = vbLf Case 2 pPtOpts.Message = vbLf Case 3 pPtOpts.Message = vbLf Case 4 pPtOpts.Message = vbLf End Select
& "Clique no Segundo ponto: " & "Clique no Terceiro ponto: " & "Clique no Quarto ponto: " & "Clique no Quinto ponto: "
'' Use the previous point as the base point pPtOpts.UseBasePoint = True pPtOpts.BasePoint = pPtRes.Value pPtRes = acDoc.Editor.GetPoint(pPtOpts) colPt.Add(New Point2d(pPtRes.Value.X, pPtRes.Value.Y)) If pPtRes.Status = PromptStatus.Cancel Then Exit Sub '' Increment the counter nCounter = nCounter + 1 End While '' Create a polyline with 5 points Using acPoly As Polyline = New Polyline() acPoly.AddVertexAt(0, colPt(0), 0, 0, acPoly.AddVertexAt(1, colPt(1), 0, 0, acPoly.AddVertexAt(2, colPt(2), 0, 0, acPoly.AddVertexAt(3, colPt(3), 0, 0, acPoly.AddVertexAt(4, colPt(4), 0, 0, '' Close the polyline acPoly.Closed = True '' Query the area of the polyline Application.ShowAlertDialog("Area da Polilinha: " & _ acPoly.Area.ToString()) '' Dispose of the polyline End Using End Sub
0) 0) 0) 0) 0)
End Class
Endereos para procura na internet line vb.net for autocad code sourse criar um code sourse cad desenhando com vb desenhando grficos com vb criando menu com dll para autocad carregando dll para autocad com menu bibbon close para autocad programation for autocad code sourse >> foi onde encontrei o cdigo do cad na pg. 6 vb net programming for autocad customization, vb net programming for autocad customization, code sourse vb net for autocad cad code sourse como fazer menu autocad vb net customize in autocad ribbon
www.autodesk.com/joinadn
<CommandMethod("AddNewC")> _ Public Sub AddNewCircleTransaction() '' Obter o documento atual e banco de dados Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument Dim acCurDb As Database = acDoc.Database '' Iniciar uma transao Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction() '' Abra a tabela do bloco de leitura Dim acBlkTbl As BlockTable acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
'' Abra a tabela Bloco recorde espao do modelo para escrever Dim acBlkTblRec As BlockTableRecord acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite) '' Criar um crculo com um raio de 3 a 5,5 Dim acCirc As Circle = New Circle() acCirc.SetDatabaseDefaults() acCirc.Center = New Point3d(5, 5, 0) acCirc.Radius = 3 '' Adicione o novo objeto de espao do modelo e da transao acBlkTblRec.AppendEntity(acCirc) acTrans.AddNewlyCreatedDBObject(acCirc, True) '' Confirme as alteraes e dispor da transao acTrans.Commit() End Using
'
UM FORMULARIO
' comando a ser digitado "Cal" maiusculo ou minusculo no autocad <Autodesk.AutoCAD.Runtime.CommandMethod("Cal")> _ Public Sub FormCalculadoraMCO() ''MOSTRA O FORMULARIO "Form1" ' formi a variavel ' FormCaptura o nome do formulrio Dim formi As New FormArea If formi.ShowDialog <> Windows.Forms.DialogResult.OK Then Exit Sub ' inicio do codigo End Sub