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

How to get coordinates!

5 REPLIES 5
Reply
Message 1 of 6
gilseorin
326 Views, 5 Replies

How to get coordinates!

Hi, all!
Any help, I would be happy and appreciated.
First, I pick a point on the Model Space of the CAD.
Second, I want to get the point's coordinates in my text file named 'Test.txt ' .

Sub CoordinatesToText()
Dim AutoCADObject As AcadApplication = GetObject(, "AutoCAD.Application")
Dim Thisdrawing As Object = AutoCADObject.ActiveDocument

Dim OpenFile As String
OpenFile = "C:\Test.txt"
Dim filenumber As Integer
filenumber = 1
Dim varPnt As Object
varPnt = Thisdrawing.Utility.GetPoint(, vbCrLf & "Pick a point to export to the Text.txt file:")
OpenWrite(OpenFile)
Print(filenumber, varPnt)
End Sub
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: gilseorin

Dim varPnt As Object

varPnt = Thisdrawing.Utility.GetPoint(, vbCrLf & "Pick a point to export to
the Text.txt file:")

MsgBox "x=" & varPnt(0) & vbcr & "y=" & varPnt(1) & "z=" & varPnt(2)

...



wrote in message news:5421196@discussion.autodesk.com...
Hi, all!
Any help, I would be happy and appreciated.
First, I pick a point on the Model Space of the CAD.
Second, I want to get the point's coordinates in my text file named
'Test.txt ' .

Sub CoordinatesToText()
Dim AutoCADObject As AcadApplication = GetObject(,
"AutoCAD.Application")
Dim Thisdrawing As Object = AutoCADObject.ActiveDocument

Dim OpenFile As String
OpenFile = "C:\Test.txt"
Dim filenumber As Integer
filenumber = 1
Dim varPnt As Object
varPnt = Thisdrawing.Utility.GetPoint(, vbCrLf & "Pick a point
to export to the Text.txt file:")
OpenWrite(OpenFile)
Print(filenumber, varPnt)
End Sub
Message 3 of 6
gilseorin
in reply to: gilseorin

Sorry,but I want to confirm the information of the coordinates in the text file named 'Test.txt".
Plz, help me.
Message 4 of 6
NathTay
in reply to: gilseorin

Dim objFile As System.IO.StreamWriter = My.Computer.FileSystem.OpenTextFileWriter("C:\Test.txt"
, False)
objFile.WriteLine(varPnt.ToString)
objFile.Close()
Message 5 of 6
NathTay
in reply to: gilseorin

Sorry replace varPnt.ToString with what Norman posted for his msgbox.

Regards - Nathan
Message 6 of 6
gilseorin
in reply to: gilseorin

Thank you very much.
I corrected your code a bit.
objFile.WriteLine(varPnt(0).ToString & vbTab & varPnt(1).ToString & vbTab & varPnt(2) & vbCrLf)

It does a good job.
May happy day!

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