How to access point through reference or ID

How to access point through reference or ID

Anonymous
Not applicable
1,145 Views
9 Replies
Message 1 of 10

How to access point through reference or ID

Anonymous
Not applicable

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

0 Likes
Accepted solutions (1)
1,146 Views
9 Replies
Replies (9)
Message 2 of 10

truss_85
Advocate
Advocate

You can use selection sets to do what ever you want. Filter ony points you needed.

0 Likes
Message 3 of 10

Alfred.NESWADBA
Consultant
Consultant

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 -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 4 of 10

Anonymous
Not applicable

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

0 Likes
Message 5 of 10

Anonymous
Not applicable

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

 

0 Likes
Message 6 of 10

Alfred.NESWADBA
Consultant
Consultant

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 -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 7 of 10

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

ok, our posts crossed. Anyway ==> can you read what you copied into the message-body (without CRLF)?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 8 of 10

Anonymous
Not applicable

Hi Alfred,

you are to fast for me :;,  Now I hope the code is readable.

 

Thanks Michal

0 Likes
Message 9 of 10

Alfred.NESWADBA
Consultant
Consultant
Accepted solution

Hi,

 

change this statement

 

pointCollection.Add (objPoint)

to that statement

Call pointCollection.Add(objPoint)

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 10 of 10

Anonymous
Not applicable

Thanks a lot. Now works fine. I will have to look for "Call" meaning.

 

Michal

0 Likes