.NET

Reply
Distinguished Contributor
gilseorin
Posts: 177
Registered: ‎09-05-2006
Message 1 of 6 (75 Views)

How to get coordinates!

75 Views, 5 Replies
12-11-2006 03:13 AM
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
*Norman Yuan
Message 2 of 6 (75 Views)

Re: How to get coordinates!

12-11-2006 06:02 AM 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
Distinguished Contributor
gilseorin
Posts: 177
Registered: ‎09-05-2006
Message 3 of 6 (75 Views)

Re: How to get coordinates!

12-11-2006 06:28 AM 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.
Distinguished Contributor
NathTay
Posts: 1,691
Registered: ‎12-15-2003
Message 4 of 6 (75 Views)

Re: How to get coordinates!

12-11-2006 01:15 PM in reply to: gilseorin
Dim objFile As System.IO.StreamWriter = My.Computer.FileSystem.OpenTextFileWriter("C:\Test.txt"
, False)
objFile.WriteLine(varPnt.ToString)
objFile.Close()
Distinguished Contributor
NathTay
Posts: 1,691
Registered: ‎12-15-2003
Message 5 of 6 (75 Views)

Re: How to get coordinates!

12-11-2006 01:23 PM in reply to: gilseorin
Sorry replace varPnt.ToString with what Norman posted for his msgbox.

Regards - Nathan
Distinguished Contributor
gilseorin
Posts: 177
Registered: ‎09-05-2006
Message 6 of 6 (75 Views)

Re: How to get coordinates!

12-11-2006 03:11 PM 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!
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!