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

Insertion Point as Object

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
607 Views, 7 Replies

Insertion Point as Object

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)
7 REPLIES 7
Message 2 of 8
jimmie_fulton
in reply to: Anonymous

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\".
Message 3 of 8
Anonymous
in reply to: Anonymous

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
Message 4 of 8
jimmie_fulton
in reply to: Anonymous

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
Message 5 of 8
egcallis
in reply to: Anonymous

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
Message 6 of 8
Anonymous
in reply to: Anonymous

thanks for replay, It keeps telling me that

Additional information: Object reference not set to an instance of an object.
Message 7 of 8
jimmie_fulton
in reply to: Anonymous

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
Message 8 of 8
jayapradha
in reply to: Anonymous

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

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