• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 967
  • Last Modified:

What triggers events in autocad vba?

So I just started programming in Autocad VBA.  I have have list events, but not what triggers them.  Does anyone have a good reference that tells what they all mean.  Some are obvious, but some aren't.  What I need right now is to know if adding a project triggers an event, and if so, which one.  (Tools->Macro->VBA Manager->New)
0
iwtblj247
Asked:
iwtblj247
  • 2
1 Solution
 
borgunitCommented:
It sounds like you are referring to the basics of Object Oriented Programming. Start with the Help in AutoCAD and do a few starter exercises. These may help also.

http://www.hyperpics.com/eBooks/Intro_to_VBA_for_AutoCAD/Introduction_to_VBA_for_AutoCAD_(Mini_Guide).pdf

http://www.tenlinks.com/CAD/USERS/AutoCAD/vba.htm
0
 
darrenmcwiCommented:
Without trying all of them, you can only make a guess.

I doubt ARXLoaded will do it although it would if you were ARX programming.

Modified may do it but I doubt it, it's designed for things like layers or entities. MAybe VBA projects are internally stored in a way they would trigger it but I don't think so.

Same with ObjectAdded,ObjectModified,ObjectErased I would guess those won't either...less lileky than  the Modified event.

SysVarChanged but it would depend if loading a new VBA project changed any sysvars. I'm not aware if any iff the top of my head but I didn't look either so there may be.

Your best bet is the EndCommand event where you'd have to then check which command just ended.

The others I wouldn't even bother to try.

I wounldn't spend much time with VBA. Microsoft doesn't support it any longer and Autodesk is providing it only as an additinoal download and install. Might better try Lisp or VB.Net/C#.

0
 
JJ_DelftCommented:

Hi iwtblj247,

You're Q is not entirely clear to me, buy you should think of AuotCAD VBA just as all OOP:
Study the objectmodel. Forn there you'll get the idea of it all.

Any app notices the windows event loop, so to build an ACAD app is the easyest w. a VBA dialog responce.

Here's a sample:
Make a form with a textbox : Text1
                            3 buttons : cmdHelp, cmdCancel  and cmdApply
                 and a spinbutton : SpinButton1
Now, add the code as shown in the Snippet


'==============================
'the form - frmChangePoly
'------------------------------
Option Explicit
 
Private Sub cmdApply_Click()
'           ==============
    Dim elem As Object
    Dim Width As Double
 
    Width = CDbl(Text1.Text)
    If Width < 0# Then
        MsgBox "Please enter a positive value for the width"
    Else
        
        For Each elem In ThisDrawing.ModelSpace
            With elem
                If StrComp(.ObjectName, "AcDbPolyLine", 1) = 0 Then
                
                    ' there's a hit..
                    .ConstantWidth = Width
                    '.Update  ' Uncomment to see each change
                End If
            End With
        Next elem
        ThisDrawing.Application.Update ' Do one Update
    End If
End Sub
 
Private Sub cmdCancel_Click()
    Unload Me
End Sub
 
Private Sub cmdHelp_Click()
    MsgBox "Changes the width of all polylines in ModelSpace." & Chr(13) & Chr(13) _
    & "You must first draw a polyline using the PLINE command."
End Sub
 
Private Sub SpinButton1_Change()
    Text1.Text = SpinButton1.Value / 10
End Sub
 
' === EOF ===
 
 
'==========================
'The module - modChangePoly
'--------------------------
Option Explicit
 
Sub ChgPolyWidth()
    frmChangePoly.Show
End Sub
 
'=== EOF ===

Open in new window

0
 
darrenmcwiCommented:
Did you still need assistance with this issue? Let us know and we'll try to help out.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now