Hi,
I am new to VBA, AutoCad, ActiveX and all this stuff. It is probably obvious but I can not figer out for hours. How can I store reference to AcadPoint for later use? I am inserting hunderds of point to ModelSpace. In each loop I have reference to created point. But how to store this reference for later use in some array, collection...? The Colletion.Add(objPoint) does not work.
Set objPoint = ThisDrawing.ModelSpace.AddPoint(point)
Thanks Michal
Solved! Go to Solution.
Solved by Alfred.NESWADBA. Go to Solution.
Hi,
>> The Colletion.Add(objPoint) does not work
Why not? If you create a new collection (VBA-collection object) you can add any item from any type (at least derived from "Object"). And to have a key for the collection - if you need that - you can use the Handle of your AcadPoint-object.
If that does not work for you then show that part of code that makes difficulties, plus mark the line where you get the exception and let us know what type if exception that is.
- alfred -
OK, but how to filter point out? Do I have store some Id? My idea was store AcadPoint Object reference in Collection for live of script. But it throughs me error. 438.
Please look at my code in other reply.
Michal
Here is my code:
Sub gts_CoorImport(fileName As String) Dim lineData As String Dim pointArray As Variant Dim objPoint As AcadPoint Dim point(0 To 2) As Double Dim pointText As String 'Dim pointList(100) As AcadPoint I also tried Array :( Dim pointCollection As New Collection Dim testCollection As New Collection Open fileName For Input As #1 While Not EOF(1) Line Input #1, lineData pointArray = gtfun_SplitCoorLine2(lineData) point(0) = pointArray(1) point(1) = pointArray(2) point(2) = pointArray(3) pointText = pointArray(0) + pointArray(4) Set objPoint = ThisDrawing.ModelSpace.AddPoint(point) testCollection.Add ("Test item") 'Works fine 'pointCollection.Add (objPoint) 'Throughs error 438, Object does not support this property or method Wend Close #1 ThisDrawing.Application.ZoomAll End Sub
Hi,
>> Please look at my code in other reply.
Where do I find "other reply"? I just found an initial message and one reply, nothing else (and the 2 lines of code in the initial message don't see how "Colletion" was declared - for Colletion.Add(objPoint) - I also don't see how "point" was declared for that statement ThisDrawing.ModelSpace.AddPoint(point) and I don't know at wich line the message pops up and I don't want to search now for the meaning if err-number 438.
You make it not easy for others that try to help you.
- alfred -
Hi,
ok, our posts crossed. Anyway ==> can you read what you copied into the message-body (without CRLF)?
- alfred -
Hi Alfred,
you are to fast for me :;, Now I hope the code is readable.
Thanks Michal
Hi,
change this statement
pointCollection.Add (objPoint)
to that statement
Call pointCollection.Add(objPoint)
- alfred -
Thanks a lot. Now works fine. I will have to look for "Call" meaning.
Michal