.NET

Reply
Contributor
JohnB-HKS
Posts: 16
Registered: ‎02-14-2006
Message 1 of 8 (185 Views)

Insertion Point as Object

185 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
jimmie_fulton
Posts: 44
Registered: ‎04-06-2005
Message 2 of 8 (185 Views)

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
JohnB-HKS
Posts: 16
Registered: ‎02-14-2006
Message 3 of 8 (185 Views)

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
jimmie_fulton
Posts: 44
Registered: ‎04-06-2005
Message 4 of 8 (185 Views)

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
egcallis
Posts: 73
Registered: ‎06-03-2004
Message 5 of 8 (185 Views)

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
JohnB-HKS
Posts: 16
Registered: ‎02-14-2006
Message 6 of 8 (185 Views)

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
jimmie_fulton
Posts: 44
Registered: ‎04-06-2005
Message 7 of 8 (185 Views)

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
jayapradha
Posts: 7
Registered: ‎02-28-2006
Message 8 of 8 (185 Views)

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community