.NET

Reply
Contributor
16 Posts
0 Kudos
Registered: ‎02-14-2006
Post 1 of 8

Insertion Point as Object

190 Views, 7 Replies
02-16-2006 07:02 AM
In the area *** I need to set the insertion point as Object. Dose anyone know that best way to get the user set insertion point in VB.NET


Dim acDoc As AcadDocument
Dim objBlock As AcadBlockReference

objBlock = acDoc.ModelSpace.InsertBlock(***, "c:\eq-flow.dwg", 1, 1, 1, 0)
Active Contributor
44 Posts
0 Kudos
Registered: ‎04-06-2005
Post 2 of 8

Re: Insertion Point as Object

02-16-2006 09:22 AM in reply to: JohnB-HKS
When using COM interop you might try something like:

Double point = (Double[])acDoc.Utility.GetPoint(System.Type.Missing,"Pick a point");

Be sure to trap that in a try/catch/finally block, as the user could cancel the prompt.

For interacting with the user using the managed API (much better than using COM), there are some good examples in the ObjectARX 2006 SDK. Look for prompt samples in "ObjectARX 2006\samples\dotNet\Prompts\".
Contributor
16 Posts
0 Kudos
Registered: ‎02-14-2006
Post 3 of 8

Re: Insertion Point as Object

02-16-2006 09:46 AM in reply to: JohnB-HKS
thanks for the replay It keeps telling me that the

Dim acDoc As AcadDocument
Dim objBlock As AcadBlockReference
Dim inpt As Double
inpt = (Double[])acDoc.Utility.GetPoint(System.Type.Missing,"Pick a point")
objBlock = acDoc.ModelSpace.InsertBlock(inpt, "c:\eq-flow.dwg", 1, 1, 1, 0)

it tells me that Double is an object and can't be an exprestion and that the idenifier is exspected
Active Contributor
44 Posts
0 Kudos
Registered: ‎04-06-2005
Post 4 of 8

Re: Insertion Point as Object

02-16-2006 11:10 AM in reply to: JohnB-HKS
Sorry, that was c# syntax that I provided. You'll need to use VB.Net's equivalent of casting.

I don't use VB.Net, but I think you might try something like this:
Dim inpt as Double()
inpt = CType(acDoc.Utility.GetPoint(System.Type.Missing,"Pick a point"), Double())

You may be able to do just this:
Dim inpt as Double()
inpt = acDoc.Utility.GetPoint(System.Type.Missing,"Pick a point")

Be aware that you are getting back an array of doubles, not a single double as you have in your code Message was edited by: Jimmie Fulton
Valued Contributor
73 Posts
0 Kudos
Registered: ‎06-03-2004
Post 5 of 8

Re: Insertion Point as Object

02-16-2006 12:12 PM in reply to: JohnB-HKS
Use an Object as in

Dim inpt as Object
Try
inpt = acDoc.Utility.GetPoint(,"Pick a point")
Catch ex as Exception
' Can Put Msgbox or error checking/goto here
End
Contributor
16 Posts
0 Kudos
Registered: ‎02-14-2006
Post 6 of 8

Re: Insertion Point as Object

02-16-2006 12:28 PM in reply to: JohnB-HKS
thanks for replay, It keeps telling me that

Additional information: Object reference not set to an instance of an object.
Active Contributor
44 Posts
0 Kudos
Registered: ‎04-06-2005
Post 7 of 8

Re: Insertion Point as Object

02-16-2006 03:13 PM in reply to: JohnB-HKS
Here is full working code:

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Interop

Public Class Class1

Public Function test()

Dim aDoc As AcadDocument = Application.DocumentManager.MdiActiveDocument.AcadDocument
Dim input As Double()
Try
input = aDoc.Utility.GetPoint(System.Type.Missing, "\rPick a point: ")
For Each point As Double In input
System.Diagnostics.Debug.WriteLine(point.ToString())
Next
Catch
System.Diagnostics.Debug.WriteLine("Oops!")
End Try

End Function

End Class
Active Member
7 Posts
0 Kudos
Registered: ‎02-28-2006
Post 8 of 8

Re: Insertion Point as Object

03-01-2006 02:51 AM in reply to: JohnB-HKS
Hai

I am using the same code what is given.
but i got this error.

Additional information: Object reference not set to an instance of an object.

Dim aDoc As AcadDocument here it is giving the Exception i.e Object reference not set to an instance of an object.

Editor and Database classes also not recognizing.
for all the classes it giving the same error.

How can I rectify this error. please help to me

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Interop

Public Class Class1

Public Function test()

Dim aDoc As AcadDocument = Application.DocumentManager.MdiActiveDocument.AcadDocument
Dim input As Double()
Try
input = aDoc.Utility.GetPoint(System.Type.Missing, "\rPick a point: ")
For Each point As Double In input
System.Diagnostics.Debug.WriteLine(point.ToString())
Next
Catch
System.Diagnostics.Debug.WriteLine("Oops!")
End Try

End Function

End Class
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!