Hi all,
This should be quite simple for many of you, I believe.
I need to create 3dpolyline interactively by clicking points on the screen. It seems to me that the SendCommand can't be used in my case since I can't make program hold until the user enters the object and also, it doesn't return a reference to the object created. Please correct me if I am wrong.
The problem I have is that GetPoint returns Object (instead of Point3D) which can not be added to pointCollection. Could you give me some suggestions?
The logic should go like this:
Dim myPoints As New AcadNetGeometry.Point3dCollection
Dim pt3D As AcadNetGeometry.Point3d
Do While True
Try
pt3D = g_oCivil3DDoc.Utility.GetPoint(, "Pick a point:")
myPoints.Add(pt3D)
Catch ex As Exception
Exit Do
End Try
Loop
Dim myPLine3D As New AcadNetDbServices.Polyline3d(AcadNetDbServices.Poly3dType.SimplePoly, myPoints, True)
Thanx,
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
Hi,
You better not use Utilily.Getpoint.
Try This:
Dim ThisEditor As Autodesk.AutoCAD.EditorInput.Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim PrpRes As Autodesk.AutoCAD.EditorInput.PromptPointResult = ThisEditor.GetPoint(ControlChars.Lf & "Select a point: ")
If PrpRes.Status = Autodesk.AutoCAD.EditorInput.PromptStatus.OK Then
Dim MyPoint As Point3d = PrpRes.Value
End If
You can refer to Autodesk .NET documentation.
Good Luck!
Bert
Obviously, you are using COM API's GetPoint() method, which returns an object - an array of Double type with 3 elements. It is not Autodesk.AutoCAD.Geometry.Point3dCollection. Thus, your code does not work.
First of all, why use COM API's AcadUtility.GetPoint() method at all while you are doing managed API project? You should use:
Editor.GetPoint() in conjunction with PromptPointOptions/PromptPointResult object to get user-picked point as Point3d value.
If you HAVE TO use AcadUtility.GetPoint() for some very odd reason in a managed API project (what it could be, I wonder), then you should create a Point3d struct from the returned 3-element array:
Do While Trye
Try
Dim pt As object=g_oCivil3DDoc.Utility.GetPoint(,"Pick point:")
Point3d p=New Point3d(pt(0),pt(1),pt(2))
myPoints.Add(p)
Catch
Exit Do
End Try
Loop
Norman Yuan
Thanx for the replies!
Obviously, I need to fully understand basic conceps first.
Could you refer me to some good resources i.e. ebooks, tutorials, etc. as to vb.NET for AutoCAD. In fact, I was able to download pretty useful AutoCAD Civil 3D Developer's Guide, however, I haven't found any good reference of pure AutoCAD .NET (except the on-line AutoCAD .NET Developer's Guide which I don't find very well structured and explanatory).
What would you recommend?
Thanx,
Hi there,
There are sever resources.
http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html a guide by autodesk.
http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1911627 look at the autocad 2010 .net training it's in c# en VB.net
and a great book. By Jerry Winters called VB.NET for AutoCAD 2010 it's a level 1 book and heard he is writing a level 2 book right now.
The book can be orderd on his website. www.vbcad.com
Kind regards
Can't find what you're looking for? Ask the community or share your knowledge.