.NET

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

How to get coordinates!

72 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 (72 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 (72 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 (72 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 (72 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 (72 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!

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