Can it be done?

Can it be done?

Anonymous
Not applicable
1,150 Views
3 Replies
Message 1 of 4

Can it be done?

Anonymous
Not applicable

Hi, I'm new to VBA and LISP, and I could use some help here...

 

I have an algorithm in C++ which I want to re-write to create a new app for autocad

 

I need the app to collect text from multiple drawings --> process it --> create new dwg file.

Could someone please give me some ideas how to start?

 

should I make a lisp that calls VBA? or a VBA that calls lisps?

 

from the little I know I was thinking about a lisp that call a VBA with execute button,

if you press the execute button, you call a function that enables you to select all the text in drawing number 1,

afterwards you can press another buttom to select all the text in drawing number 2 and so on...

 

what do you think?

 

0 Likes
1,151 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

of course it can

 

and it can be done all in VBA

 

I'd suggest you to use SelectionSet object to gather all Text objects within a document object

then you can loop through the selectionset and get the text out of every single Text object through its TextString property 

 

for instance you could gather them in a string array to be processed by your algortihm

 

 

    With ssetObj ' <-- ssetObj is a valid selectionset object you created and filled with all current drawing text objects
            ReDim texts(0 To .Count) As String ' dimension a string array to collect all text objects string
            Dim iText As Long
            For iText = 0 To .Count - 1 ' loop through selectionset
                texts(iText) = .Item(iText).TextString ' fill corresponding string array element with text object content
            Next
        End If
    End With
0 Likes
Message 3 of 4

Anonymous
Not applicable

after which line of code will I gain the ability to select objects in the drawing?

0 Likes
Message 4 of 4

Anonymous
Not applicable

my code snippet assumes you've already set and filled a valid SelectionSet  object

 

as to how to do that, there's plenty of examples all over the web as well in the AutoCAD ActiveX Reference Guide, from which I'm copying and pasting the following example:

 

Sub Example_SelectOnScreen()
    ' This example adds objects to a selection set by prompting the user
    ' to select ones to add.
    
    AppActivate ThisDrawing.Application.Caption
    
    ' Create the selection set
    Dim ssetObj As AcadSelectionSet
    Set ssetObj = ThisDrawing.SelectionSets.Add("TEST_SSET")
    
    ' Add objects to a selection set by prompting user to select on the screen
    ssetObj.SelectOnScreen
    
End Sub

 

0 Likes