VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to access point through reference or ID

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
majk333
766 Views, 9 Replies

How to access point through reference or ID

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

Tags (3)
9 REPLIES 9
Message 2 of 10
truss_85
in reply to: majk333

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

Message 3 of 10
Alfred.NESWADBA
in reply to: majk333

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 4 of 10
majk333
in reply to: majk333

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

Message 5 of 10
majk333
in reply to: Alfred.NESWADBA

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

 

Message 6 of 10
Alfred.NESWADBA
in reply to: majk333

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 7 of 10
Alfred.NESWADBA
in reply to: majk333

Hi,

 

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

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 8 of 10
majk333
in reply to: Alfred.NESWADBA

Hi Alfred,

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

 

Thanks Michal

Message 9 of 10
Alfred.NESWADBA
in reply to: majk333

Hi,

 

change this statement

 

pointCollection.Add (objPoint)

to that statement

Call pointCollection.Add(objPoint)

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 10 of 10
majk333
in reply to: Alfred.NESWADBA

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

 

Michal

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost