.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Code Problem im VB.NET

2 REPLIES 2
Reply
Message 1 of 3
arun.2u
279 Views, 2 Replies

Code Problem im VB.NET

i have been learning AutoCAD VB for a year long and capable of compiling program to some extend and then i came to know about .net so i downloaded Visual Basic 2005 Express edition and i have started with basic labs provided by autodesk and in the VBX i tried to mix the code form lab2 and 3 to get the desired output circle with a pick point and radius while i was capable of solving the get distance but have still problem with get point and are there and books for beginners for AutoCAD vb.net.

Here is the code i tried to Compile
"
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry

Public Class ArunCommands

' Define command 'Aruncmd1'
_
Public Sub Aruncmd1()
Try
' Type your code here
Dim poo As PromptPointOptions = New
PromptPointOptions("Specify
Center: ")
Dim por As PromptPointResult
Dim cir As Circle
Dim tbr As BlockTableRecord
Dim tb As BlockTable
Dim trans As Transaction
trans =
HostApplicationServices.WorkingDatabase().TransactionManager.StartTransa
ction()
Dim ed As Editor =
Application.DocumentManager.MdiActiveDocument.Editor
por = ed.GetPoint(poo)
If por.Status PromptStatus.OK Then
Return
End If
Dim gdis As PromptDistanceOptions = New
PromptDistanceOptions("Specify the rad: ")
Dim rad As PromptDoubleResult
Dim edc As Editor
rad = edc.GetDistance(gdis)
Dim radi As Double
radi = rad.ToString
cir = New Circle(por, Vector3d.ZAxis, radi)
tbr =
trans.GetObject(HostApplicationServices.WorkingDatabase.BlockTableId,
OpenMode.ForRead)
Dim tbid As ObjectId = tb.Item(BlockTableRecord.ModelSpace)
tbr = trans.GetObject(tbid, OpenMode.ForWrite)
tbr.AppendEntity(cir)
trans.AddNewlyCreatedDBObject(cir, True)

trans.Commit()
trans.Dispose()
Catch
MsgBox("Error Msg is: ")
End Try
End Sub

End Class
"
with regards
Arun Prasad.H
2 REPLIES 2
Message 2 of 3
deepa
in reply to: arun.2u

pls define the command before sub

_
Public Sub Aruncmd1()
Try
' Type your code here
Dim poo As PromptPointOptions = New
PromptPointOptions("Specify

try this i hope
Message 3 of 3
arun.2u
in reply to: arun.2u

Thanks for the reply
I think i have corrected the problem and capable of compiling the output dll but while i run the dll (AutoCAD) i cannot see the circle and here is the code

"
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry

Public Class ArunCommands
"CommandMethod("acir")" _
Public Sub acir()
Dim db As Database = HostApplicationServices.WorkingDatabase()
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Try
Dim poo As PromptPointOptions = New PromptPointOptions("Specify Center: ")
Dim por As PromptPointResult
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
por = ed.GetPoint(poo)
If por.Status PromptStatus.OK Then
Return
End If
Dim ecx As Double
ecx = por.Value.X
Dim ecy As Double
ecy = por.Value.Y
Dim ecz As Double
ecz = por.Value.Z
Dim cen As Point3d
cen = New Point3d(ecx, ecy, ecz)
Dim gdis As PromptDistanceOptions = New PromptDistanceOptions("Specify the rad: ")
Dim rad As PromptDoubleResult
rad = ed.GetDistance(gdis)
Dim radi As Double
radi = rad.ToString
Dim cir As Circle = New Circle(New Point3d(ecx, ecy, ecz), Vector3d.ZAxis, radi)
Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead)
Dim bts As BlockTableRecord = trans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite)

bts.AppendEntity(cir)
trans.AddNewlyCreatedDBObject(cir, True)

trans.Commit()
Catch ex As System.Exception
trans.Dispose()
MsgBox("Error Msg is: " + ex.Message)
End Try
End Sub

End Class

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost