Visual Basic Customization

Reply
New Member
iymalik
Posts: 1
Registered: ‎10-20-2011
Message 1 of 1 (1,170 Views)

AUTOCAD-vba6 : Runtime Error 429 : ActiveX Component Can't Create Object

1170 Views, 0 Replies
10-20-2011 02:17 PM

Hey all,

 

I am Using a  Windows 7 based x64 system I am working on AUTOCAD 2010   with VBA 6 but  i am getting teh error "Runtime Error 429 : ActiveX Component Can't Create Object " .

 

I started doing this project on a 32 bit system and  it worked fine .But , since i moved to 64 bit system,I get this error whenever i execute a subroutine that  has to creat something in AUTOCAD.Please see the  code of related module below.


I have tried Autocad 2011 also but  problem does not solve.

 

Would appreciate your help a lot .

 

Best Regards,

Irfan

 

'--------------------------------
''         RANDOM WALK
'--------------------------------


' Global Data

' random step
Private Type RStep
    L As Double     ' step length
    a As Double     ' absolute step angle
    m As Double     ' mass value
    x(2) As Double  ' step position (x,y,z)
End Type

' input data
Dim start(2) As Double  ' starting coordinates x,y,z
Dim LRnd(1) As Double   ' specification of the random length
                        ' (0): mean value / (1): amplitude
Dim ARnd(1) As Double   ' specification of the random angle
Dim MRnd(1) As Double   ' specification of the random mass

Dim Steps As Integer    ' number of steps
Dim RSteps() As RStep   ' array of RStep-items


' Input Data

' setup the input data for the walk
Sub SetInputData()

    ' setup the starting point
    start(0) = 0#
    start(1) = 0#
    start(2) = 0#
    
    ' setup the random length
    LRnd(0) = 100#   ' mean value
    LRnd(1) = 20#    ' amplitude

    ' setup the random angle
    ARnd(0) = 30#
    ARnd(1) = 180#

    ' setup the random mass
    MRnd(0) = 1#        ' 1 kg
    MRnd(1) = 0.4

    ' number of steps
    Steps = 100

End Sub


' Calculate the data for the step i
'  i range from 1 to Steps
Sub GetStep(i As Integer)

    ' Error Check
    If i < 2 Then Exit Sub      ' lower bound check
    If i > Steps Then Exit Sub  ' upper bound check

    ' calculate the new absolute angle
    RSteps(i).a = RSteps(i).a + RSteps(i - 1).a

    ' calculate the step position
    degrad = Atn(1) / 45#
    RSteps(i).x(0) = RSteps(i).L * Cos(RSteps(i).a * degrad)
    RSteps(i).x(1) = RSteps(i).L * Sin(RSteps(i).a * degrad)

    ' calculate the absolute position
    RSteps(i).x(0) = RSteps(i).x(0) + RSteps(i - 1).x(0)
    RSteps(i).x(1) = RSteps(i).x(1) + RSteps(i - 1).x(1)

    ' calculate or initilize the z - coordinate
    RSteps(i).x(2) = 0#

End Sub


' Main routine: Random Walk

Sub randomwalk()

    Dim i As Integer

    ' setup input data
    Call SetInputData
    
    ' initializing the random generator
    Call Randomize
    
    ' setup the used memory
    ReDim RSteps(1 To Steps)
    
    ' initialization
    RSteps(1).L = 0#
    RSteps(1).a = 0#
    RSteps(1).x(0) = start(0)
    RSteps(1).x(1) = start(1)
    RSteps(1).x(2) = start(2)
    
    ' create a new log file
    Call InitLog(1)
    
    ' print a header section
    s$ = "  i           L           A           x           y           z           M"
    AppendLog (s$)
    s$ = "---------------------------------------------------------------------------"
    AppendLog (s$)
    
    ' calculate the next steps
    For i = 2 To Steps
    
        ' next step length
        RSteps(i).L = LRnd(0) + (Rnd * 2# - 1) * LRnd(1)
        
        ' next angle: relative angle!
        RSteps(i).a = ARnd(0) + (Rnd * 2# - 1) * ARnd(1)
        
        ' next mass
        RSteps(i).m = MRnd(0) + (Rnd * 2# - 1) * MRnd(1)
    
        ' calculate the data for the next step
        Call GetStep(i)
    
        ' list the new values
        s$ = Format(i, "000") + formatdouble(RSteps(i).L, 12, "0.00") _
                              + formatdouble(RSteps(i).a, 12, "0.00") _
                              + formatdouble(RSteps(i).x(0), 12, "0.00") _
                              + formatdouble(RSteps(i).x(1), 12, "0.00") _
                              + formatdouble(RSteps(i).x(2), 12, "0.00") _
                              + formatdouble(RSteps(i).m, 12, "0.000")

        AppendLog (s$)
    
    Next

    ' plot the path with Autocad Line Objects
    Call plotpath

    MsgBox "Rand Path created!", vbInformation, "Info"

End Sub

' plot the path of the Random Walk
Sub plotpath()

    ' create a new instance of a true type color object
    Dim Color As New AcadAcCmColor

    ' color array of rgb-values
    Dim c(2) As Integer
    c(0) = 45       ' red
    c(1) = 155      ' green
    c(2) = 255      ' blue

    ' reset the modelspace
    Call resetmodelspace

    ' create line objects and spheres
    For i = 2 To Steps
        '                                          Startpoint       Endpoint
        Set line = ThisDrawing.ModelSpace.AddLine(RSteps(i - 1).x, RSteps(i).x)
        Call Color.SetRGB(255, 0, 0)
        line.TrueColor = Color
        
        ' create a new mass instance
        Set m = New Mass
        ' and call it's create function
        If Not m.create(RSteps(i).m, RSteps(i).x, c) Then
            AppendLog ("*** Error: Sphere " & i & " can not be created!")
        End If
        
    Next

End Sub



 




Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.