.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

equivalent to arx "acedSetStatusBarProgressMeter" ?

26 REPLIES 26
Reply
Message 1 of 27
newArch
1166 Views, 26 Replies

equivalent to arx "acedSetStatusBarProgressMeter" ?

hello

what is the equivalent to arx "acedSetStatusBarProgressMeter" ?
In other word how can i access to AutoCad StatusBarProgressMeter?

Thanks in advanced.
26 REPLIES 26
Message 2 of 27
GStevens
in reply to: newArch

newArch,

Did you able to figure out how to implement acedSetStatusBarProgressMeter in .NET? If you do kindly teach me how to do it because I can't figure out how to declare "const char*" using P/Invoke and unsafe code.

Thank you in advance.
GStevens
Message 3 of 27
Anonymous
in reply to: newArch

[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint = ?acedSetStatusBarProgressMeter@@YAHPBDHH@Z)]
extern public static int acedSetStatusBarProgressMeter(string msg, int minpos, int maxpos);


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5181853@discussion.autodesk.com...
newArch,

Did you able to figure out how to implement acedSetStatusBarProgressMeter in .NET? If you do kindly teach me how to do it because I can't figure out how to declare "const char*" using P/Invoke and unsafe code.

Thank you in advance.
GStevens
Message 4 of 27
GStevens
in reply to: newArch

Tony,
Thank you for your help but I encountered an exception as "Unable to find an entry point named acedSetStatusBarProgressMeter in DLL acad.exe.".

These are my declarations and of course I had a reference to the following DLL's:
Autodesk.AutoCAD.Interop.dll
Autodesk.AutoCAD.Interop.Common.dll

[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport(
"acad.exe",
EntryPoint="acedSetStatusBarProgressMeter",
CallingConvention=CallingConvention.Cdecl)]
extern public static int acedSetStatusBarProgressMeter( string label, int nMinPos, int nMaxPos);

[DllImport(
"acad.exe",
EntryPoint="acedSetStatusBarProgressMeterPos",
CallingConvention=CallingConvention.Cdecl)]
extern public static int acedSetStatusBarProgressMeterPos(int nPos);

[DllImport(
"acad.exe",
EntryPoint="acedRestoreStatusBar",
CallingConvention=CallingConvention.Cdecl)]
extern public static void acedRestoreStatusBar();

Please tell me what do I missed?

This is the detailed error message:

{"Unable to find an entry point named acedSetStatusBarProgressMeter in DLL acad.exe." }
[System.EntryPointNotFoundException]: {System.EntryPointNotFoundException}
System.Object: {System.EntryPointNotFoundException}
_COMPlusExceptionCode: -532459699
_className: null
_exceptionMethod: null
_exceptionMethodString: null
_message: "Unable to find an entry point named acedSetStatusBarProgressMeter in DLL acad.exe."
_innerException: null
_helpURL: null
_stackTrace: {System.Array}
_stackTraceString: null
_remoteStackTraceString: null
_remoteStackIndex: 0
_HResult: -2146233053
_source: null
_xptrs: 0
_xcode: -532459699
Message: "Unable to find an entry point named acedSetStatusBarProgressMeter in DLL acad.exe."
InnerException: null
TargetSite: {System.Reflection.RuntimeMethodInfo}
StackTrace: " at Bsdc.Acad.Cmd.acedSetStatusBarProgressMeter(String label, Int32 nMinPos, Int32 nMaxPos)
at Bsdc.VolumeCalculation.ColVolume.ComputeVolumes(Point3d sp, Int32 nrows, Int32 ncols) in e:\volume\csmgdacadvolcalc\csmgdacadvolcalc\colvolume.cs:line 343
at Bsdc.VolumeCalculation.ColVolume..ctor(Point3d sp, Int32 nrows, Int32 ncols) in e:\volume\csmgdacadvolcalc\csmgdacadvolcalc\colvolume.cs:line 37
at Bsdc.VolumeCalculation.frmVolume.VolCalcMulti() in e:\volume\csmgdacadvolcalc\csmgdacadvolcalc\frmvolume.cs:line 1066"
HelpLink: ""
Source: "Bsdc.VolumeCalculation"
HResult: -2146233053


Thank you in advance.

GStevens
Message 5 of 27
Anonymous
in reply to: newArch

Take another look at my post, and note the EntryPoint parameter.
It doesn't look anything like the one you're using below.

Here is a C# class that wraps the progress meter:

http://www.caddzone.com/StatusBarProgressMeter.cs

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5182740@discussion.autodesk.com...
Tony,
Thank you for your help but I encountered an exception as "Unable to find an entry point named acedSetStatusBarProgressMeter in DLL acad.exe.".

These are my declarations and of course I had a reference to the following DLL's:
Autodesk.AutoCAD.Interop.dll
Autodesk.AutoCAD.Interop.Common.dll

[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport(
"acad.exe",
EntryPoint="acedSetStatusBarProgressMeter",
CallingConvention=CallingConvention.Cdecl)]
extern public static int acedSetStatusBarProgressMeter( string label, int nMinPos, int nMaxPos);

[DllImport(
"acad.exe",
EntryPoint="acedSetStatusBarProgressMeterPos",
CallingConvention=CallingConvention.Cdecl)]
extern public static int acedSetStatusBarProgressMeterPos(int nPos);

[DllImport(
"acad.exe",
EntryPoint="acedRestoreStatusBar",
CallingConvention=CallingConvention.Cdecl)]
extern public static void acedRestoreStatusBar();

Please tell me what do I missed?

This is the detailed error message:

{"Unable to find an entry point named acedSetStatusBarProgressMeter in DLL acad.exe." }
[System.EntryPointNotFoundException]: {System.EntryPointNotFoundException}
System.Object: {System.EntryPointNotFoundException}
_COMPlusExceptionCode: -532459699
_className: null
_exceptionMethod: null
_exceptionMethodString: null
_message: "Unable to find an entry point named acedSetStatusBarProgressMeter in DLL acad.exe."
_innerException: null
_helpURL: null
_stackTrace: {System.Array}
_stackTraceString: null
_remoteStackTraceString: null
_remoteStackIndex: 0
_HResult: -2146233053
_source: null
_xptrs: 0
_xcode: -532459699
Message: "Unable to find an entry point named acedSetStatusBarProgressMeter in DLL acad.exe."
InnerException: null
TargetSite: {System.Reflection.RuntimeMethodInfo}
StackTrace: " at Bsdc.Acad.Cmd.acedSetStatusBarProgressMeter(String label, Int32 nMinPos, Int32 nMaxPos)
at Bsdc.VolumeCalculation.ColVolume.ComputeVolumes(Point3d sp, Int32 nrows, Int32 ncols) in e:\volume\csmgdacadvolcalc\csmgdacadvolcalc\colvolume.cs:line 343
at Bsdc.VolumeCalculation.ColVolume..ctor(Point3d sp, Int32 nrows, Int32 ncols) in e:\volume\csmgdacadvolcalc\csmgdacadvolcalc\colvolume.cs:line 37
at Bsdc.VolumeCalculation.frmVolume.VolCalcMulti() in e:\volume\csmgdacadvolcalc\csmgdacadvolcalc\frmvolume.cs:line 1066"
HelpLink: ""
Source: "Bsdc.VolumeCalculation"
HResult: -2146233053


Thank you in advance.

GStevens
Message 6 of 27
Anonymous
in reply to: newArch

Thank you, Tony, for this code.

--
Roland Feletic
Message 7 of 27
GStevens
in reply to: newArch

Tony,

Thank you so much. You are a life saver.

GStevens
Message 8 of 27
GStevens
in reply to: newArch

Tony,

Thank you for the knowledge. Now I figured it out what you are trying to say at the first time. I used dependency walker to get the function entry point.

GStevens
Message 9 of 27
Anonymous
in reply to: newArch

Now i tried your code and got a fatal error.
Unhandled e0434f4dh Exception at 7c81eb33h
Maybe i did something wrong, 😉

--
Roland Feletic
"Tony Tanzillo" schrieb im Newsbeitrag
news:5182787@discussion.autodesk.com...
Take another look at my post, and note the EntryPoint parameter.
It doesn't look anything like the one you're using below.

Here is a C# class that wraps the progress meter:

http://www.caddzone.com/StatusBarProgressMeter.cs

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5182740@discussion.autodesk.com...
Tony,
Thank you for your help but I encountered an exception as "Unable to find an
entry point named acedSetStatusBarProgressMeter in DLL acad.exe.".

These are my declarations and of course I had a reference to the following
DLL's:
Autodesk.AutoCAD.Interop.dll
Autodesk.AutoCAD.Interop.Common.dll

[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport(
"acad.exe",
EntryPoint="acedSetStatusBarProgressMeter",
CallingConvention=CallingConvention.Cdecl)]
extern public static int acedSetStatusBarProgressMeter( string label, int
nMinPos, int nMaxPos);

[DllImport(
"acad.exe",
EntryPoint="acedSetStatusBarProgressMeterPos",
CallingConvention=CallingConvention.Cdecl)]
extern public static int acedSetStatusBarProgressMeterPos(int nPos);

[DllImport(
"acad.exe",
EntryPoint="acedRestoreStatusBar",
CallingConvention=CallingConvention.Cdecl)]
extern public static void acedRestoreStatusBar();

Please tell me what do I missed?

This is the detailed error message:

{"Unable to find an entry point named acedSetStatusBarProgressMeter in DLL
acad.exe." }
[System.EntryPointNotFoundException]:
{System.EntryPointNotFoundException}
System.Object: {System.EntryPointNotFoundException}
_COMPlusExceptionCode: -532459699
_className: null
_exceptionMethod: null
_exceptionMethodString: null
_message: "Unable to find an entry point named
acedSetStatusBarProgressMeter in DLL acad.exe."
_innerException: null
_helpURL: null
_stackTrace: {System.Array}
_stackTraceString: null
_remoteStackTraceString: null
_remoteStackIndex: 0
_HResult: -2146233053
_source: null
_xptrs: 0
_xcode: -532459699
Message: "Unable to find an entry point named
acedSetStatusBarProgressMeter in DLL acad.exe."
InnerException: null
TargetSite: {System.Reflection.RuntimeMethodInfo}
StackTrace: " at Bsdc.Acad.Cmd.acedSetStatusBarProgressMeter(String
label, Int32 nMinPos, Int32 nMaxPos)
at Bsdc.VolumeCalculation.ColVolume.ComputeVolumes(Point3d sp, Int32
nrows, Int32 ncols) in
e:\volume\csmgdacadvolcalc\csmgdacadvolcalc\colvolume.cs:line 343
at Bsdc.VolumeCalculation.ColVolume..ctor(Point3d sp, Int32 nrows, Int32
ncols) in e:\volume\csmgdacadvolcalc\csmgdacadvolcalc\colvolume.cs:line 37
at Bsdc.VolumeCalculation.frmVolume.VolCalcMulti() in
e:\volume\csmgdacadvolcalc\csmgdacadvolcalc\frmvolume.cs:line 1066"
HelpLink: ""
Source: "Bsdc.VolumeCalculation"
HResult: -2146233053


Thank you in advance.

GStevens
Message 10 of 27
Anonymous
in reply to: newArch

I added the sample usage code before I
posted the file, and did not test it.

Try the updated copy I just posted.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5182763@discussion.autodesk.com...
Now i tried your code and got a fatal error.
Unhandled e0434f4dh Exception at 7c81eb33h
Maybe i did something wrong, 😉

--
Roland Feletic
"Tony Tanzillo" schrieb im Newsbeitrag
news:5182787@discussion.autodesk.com...
Take another look at my post, and note the EntryPoint parameter.
It doesn't look anything like the one you're using below.

Here is a C# class that wraps the progress meter:

http://www.caddzone.com/StatusBarProgressMeter.cs

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5182740@discussion.autodesk.com...
Tony,
Thank you for your help but I encountered an exception as "Unable to find an
entry point named acedSetStatusBarProgressMeter in DLL acad.exe.".

These are my declarations and of course I had a reference to the following
DLL's:
Autodesk.AutoCAD.Interop.dll
Autodesk.AutoCAD.Interop.Common.dll

[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport(
"acad.exe",
EntryPoint="acedSetStatusBarProgressMeter",
CallingConvention=CallingConvention.Cdecl)]
extern public static int acedSetStatusBarProgressMeter( string label, int
nMinPos, int nMaxPos);

[DllImport(
"acad.exe",
EntryPoint="acedSetStatusBarProgressMeterPos",
CallingConvention=CallingConvention.Cdecl)]
extern public static int acedSetStatusBarProgressMeterPos(int nPos);

[DllImport(
"acad.exe",
EntryPoint="acedRestoreStatusBar",
CallingConvention=CallingConvention.Cdecl)]
extern public static void acedRestoreStatusBar();

Please tell me what do I missed?

This is the detailed error message:

{"Unable to find an entry point named acedSetStatusBarProgressMeter in DLL
acad.exe." }
[System.EntryPointNotFoundException]:
{System.EntryPointNotFoundException}
System.Object: {System.EntryPointNotFoundException}
_COMPlusExceptionCode: -532459699
_className: null
_exceptionMethod: null
_exceptionMethodString: null
_message: "Unable to find an entry point named
acedSetStatusBarProgressMeter in DLL acad.exe."
_innerException: null
_helpURL: null
_stackTrace: {System.Array}
_stackTraceString: null
_remoteStackTraceString: null
_remoteStackIndex: 0
_HResult: -2146233053
_source: null
_xptrs: 0
_xcode: -532459699
Message: "Unable to find an entry point named
acedSetStatusBarProgressMeter in DLL acad.exe."
InnerException: null
TargetSite: {System.Reflection.RuntimeMethodInfo}
StackTrace: " at Bsdc.Acad.Cmd.acedSetStatusBarProgressMeter(String
label, Int32 nMinPos, Int32 nMaxPos)
at Bsdc.VolumeCalculation.ColVolume.ComputeVolumes(Point3d sp, Int32
nrows, Int32 ncols) in
e:\volume\csmgdacadvolcalc\csmgdacadvolcalc\colvolume.cs:line 343
at Bsdc.VolumeCalculation.ColVolume..ctor(Point3d sp, Int32 nrows, Int32
ncols) in e:\volume\csmgdacadvolcalc\csmgdacadvolcalc\colvolume.cs:line 37
at Bsdc.VolumeCalculation.frmVolume.VolCalcMulti() in
e:\volume\csmgdacadvolcalc\csmgdacadvolcalc\frmvolume.cs:line 1066"
HelpLink: ""
Source: "Bsdc.VolumeCalculation"
HResult: -2146233053


Thank you in advance.

GStevens
Message 11 of 27
Anonymous
in reply to: newArch

I tried it now and still got the same error. Is it possible that it does not
work in Acad2007?

--
Roland Feletic
Message 12 of 27
Anonymous
in reply to: newArch

For AutoCAD 2007:
[code]
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acad.exe", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acedSetStatusBarProgressMeter@@YAHPB_WHH@Z")]
extern public static int acedSetStatusBarProgressMeter(string msg, int minpos, int maxpos);

[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acedSetStatusBarProgressMeterPos@@YAHH@Z")]
extern public static int acedSetStatusBarProgressMeterPos(int nPos);

[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acedRestoreStatusBar@@YAXXZ")]
extern public static void acedRestoreStatusBar();

[/code]
Message 13 of 27
Anonymous
in reply to: newArch

Thank you, Alexander!
Now it works.

--
Roland Feletic
Ingenieurbuero A. Pauser Ges.m.b.H.
http://www.pauser.at

hp workstation xw4200, 3GB
quadro fx1400
AutoCAD 2007, 3DSMax 8.0 SP 2
Message 14 of 27
Anonymous
in reply to: newArch

No, it will not work as-is in 2007. Because of how
Autodesk compiles AutoCAD, when the parameter
type of a function changes, so does the exported
signature.

In fully-UNICODE 2007, the first parameter to the
function shown below is wchar_t* (previously it was
char*, in non-unicode builds). Hence, changing the
type of that parameter also caused the mangled
export name to change.

So, for 2007 you must use the following EntryPoint
name for acedSetStatusBarProgressMeter():

"?acedSetStatusBarProgressMeter@@YAHPB_WHH@Z"

The signatures of the other two functions have not
changed, because the parameters haven't changed.

So if you are currently P/Invoking native functions
that have mangled export names, and take strings
as arguments (or return strings) in R16, they will be
similarly affected, and will also require a different
EntryPoint value in R17.

Use Depends.exe to look up the new names.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5182887@discussion.autodesk.com...
I tried it now and still got the same error. Is it possible that it does not
work in Acad2007?

--
Roland Feletic
Message 15 of 27
Anonymous
in reply to: newArch

Thanks, Tony!

--
Roland Feletic
Ingenieurbuero A. Pauser Ges.m.b.H.
http://www.pauser.at

hp workstation xw4200, 3GB
quadro fx1400
AutoCAD 2007, 3DSMax 8.0 SP 2
Message 16 of 27
wesbird
in reply to: newArch

Hi Tony:
I tried to convert your code to VB.NET. after changing some code, it pass compile but crash when I run it in AutoCAD. Do you know what's wrong in my code ?

Thank you a thousand.


here is the code:
[code]
Imports System
Imports System.Collections
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.Runtime

Namespace CaddZone.AutoCAD.EditorServices

Public Class StatusBarProgressMeter
Implements IDisposable

DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, _
EnTryPoint:="?acedSetStatusBarProgressMeter@@YAHPBDHH@Z")> _
Public Shared Function acedSetStatusBarProgressMeter(ByVal msg As String, ByVal minpos As Integer, ByVal maxpos As Integer) As Integer
End Function

DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, _
EnTryPoint:="?acedSetStatusBarProgressMeterPos@@YAHH@Z")> _
Public Shared Function acedSetStatusBarProgressMeterPos(ByVal nPos As Integer) As Integer
End Function

DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, _
EnTryPoint:="?acedRestoreStatusBar@@YAXXZ")> _
Public Shared Function acedRestoreStatusBar()
End Function

Public Sub New(ByVal msg As String, ByVal count As Integer)
If count > 99 Then
m_step = count / 100
acedSetStatusBarProgressMeter(msg, 0, 100)
End If
End Sub

Protected Overrides Sub Finalize()
Dispose(False)
End Sub

Private m_step As Integer = 0
Private cnt As Integer = 0
Private disposed As Boolean = False

Public Sub ProgressStep()
cnt += 1
If m_step <> 0 And cnt Mod m_step = 0 Then
acedSetStatusBarProgressMeterPos(cnt / m_step)
End If
End Sub

Public Overloads Sub Dispose() Implements IDisposable.Dispose
Dispose(True)
End Sub

Protected Overloads Sub Dispose(ByVal disposing As Boolean)
If Not disposed Then
If m_step <> 0 Then
acedRestoreStatusBar()
End If
disposed = True
GC.SuppressFinalize(Me)
End If
End Sub

End Class

'Error: Converting Casting from C# to VB.Net

Public Class TestProgressMeter
Public Sub New()
End Sub

_
Public Shared Sub Execute()


Dim count As Integer = 10000 ' size of ArrayList (and the number of

Dim myList As ArrayList = New ArrayList(count)

Dim meter1 As New StatusBarProgressMeter("Populating ArrayList...", count)
Dim i As Integer
For i = 0 To count - 1 Step i + 1
myList.Add(i)
' waste some cpu cycles so we
' can see the progress meter:
Dim x As Integer = 0
Dim j As Integer
For j = 0 To 100000 - 1 Step j + 1
x = j + i
Next
' Update progress meter
meter1.ProgressStep()
Next
meter1.Dispose()

Dim meter2 As New StatusBarProgressMeter("Processing ArrayList...", myList.Count)
Try
Dim n As Integer
For Each n In myList

' waste some cpu cycles so we
' can see the progress meter:
Dim x As Integer = n
Dim j As Integer
For j = 0 To 100000 - 1 Step j + 1
x = j + 1
Next

' Update progress meter:
meter2.ProgressStep()
Next
Finally
meter2.Dispose()
End Try
End Sub
End Class


End Namespace


[/code]
Windows 10 64 bit, AutoCAD (ACA, Map) 2023
Message 17 of 27
Anonymous
in reply to: newArch

Sorry, I took a quick look at it, but can't see what may be
the problem.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5222434@discussion.autodesk.com...
Hi Tony:
I tried to convert your code to VB.NET. after changing some code, it pass compile but crash when I run it in AutoCAD. Do you know what's wrong in my code ?

Thank you a thousand.


here is the code:
[code]
Imports System
Imports System.Collections
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.Runtime

Namespace CaddZone.AutoCAD.EditorServices

Public Class StatusBarProgressMeter
Implements IDisposable

DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, _
EnTryPoint:="?acedSetStatusBarProgressMeter@@YAHPBDHH@Z")> _
Public Shared Function acedSetStatusBarProgressMeter(ByVal msg As String, ByVal minpos As Integer, ByVal maxpos As Integer) As Integer
End Function

DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, _
EnTryPoint:="?acedSetStatusBarProgressMeterPos@@YAHH@Z")> _
Public Shared Function acedSetStatusBarProgressMeterPos(ByVal nPos As Integer) As Integer
End Function

DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, _
EnTryPoint:="?acedRestoreStatusBar@@YAXXZ")> _
Public Shared Function acedRestoreStatusBar()
End Function

Public Sub New(ByVal msg As String, ByVal count As Integer)
If count > 99 Then
m_step = count / 100
acedSetStatusBarProgressMeter(msg, 0, 100)
End If
End Sub

Protected Overrides Sub Finalize()
Dispose(False)
End Sub

Private m_step As Integer = 0
Private cnt As Integer = 0
Private disposed As Boolean = False

Public Sub ProgressStep()
cnt += 1
If m_step <> 0 And cnt Mod m_step = 0 Then
acedSetStatusBarProgressMeterPos(cnt / m_step)
End If
End Sub

Public Overloads Sub Dispose() Implements IDisposable.Dispose
Dispose(True)
End Sub

Protected Overloads Sub Dispose(ByVal disposing As Boolean)
If Not disposed Then
If m_step <> 0 Then
acedRestoreStatusBar()
End If
disposed = True
GC.SuppressFinalize(Me)
End If
End Sub

End Class

'Error: Converting Casting from C# to VB.Net

Public Class TestProgressMeter
Public Sub New()
End Sub

_
Public Shared Sub Execute()


Dim count As Integer = 10000 ' size of ArrayList (and the number of

Dim myList As ArrayList = New ArrayList(count)

Dim meter1 As New StatusBarProgressMeter("Populating ArrayList...", count)
Dim i As Integer
For i = 0 To count - 1 Step i + 1
myList.Add(i)
' waste some cpu cycles so we
' can see the progress meter:
Dim x As Integer = 0
Dim j As Integer
For j = 0 To 100000 - 1 Step j + 1
x = j + i
Next
' Update progress meter
meter1.ProgressStep()
Next
meter1.Dispose()

Dim meter2 As New StatusBarProgressMeter("Processing ArrayList...", myList.Count)
Try
Dim n As Integer
For Each n In myList

' waste some cpu cycles so we
' can see the progress meter:
Dim x As Integer = n
Dim j As Integer
For j = 0 To 100000 - 1 Step j + 1
x = j + 1
Next

' Update progress meter:
meter2.ProgressStep()
Next
Finally
meter2.Dispose()
End Try
End Sub
End Class


End Namespace


[/code]
Message 18 of 27
Anonymous
in reply to: newArch

1) Version of AutoCAD? If it is AutoCAD 2007 you have to change:
[code]
EntryPoint:="?acedSetStatusBarProgressMeter@@YAHPBDHH@Z"
with
EntryPoint:="?acedSetStatusBarProgressMeter@@YAHPB_WHH@Z"
[/code]
2) Is it inproces application (DLL)? If no and you start AutoCAD as COM-server through COM/ActiveX model you can not use progressmeter.

3) I've tested that code in AutoCAD 2006 and found problem! 🙂 Problem is declaretion of function acedRestoreStatusBar. As far as this function return nothing it must be declared as SUB not as Function:
[code]
DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, _
EnTryPoint:="?acedRestoreStatusBar@@YAXXZ")> _
Public Shared Sub acedRestoreStatusBar()
End Sub
[/code]
With this change there are no exceptions!
Message 19 of 27
wesbird
in reply to: newArch

Thank you, Alex.
I'm sorry to forget metion my system:
AutoCAD 2006
Visual Studio .Net 2003
.Net Framework 1.1

I change Function to Sub, but still not work

I also tried another solution: use the C# version to create a dll file, create a new VB.NET project with all test code inside.
The VB test code is same as the one in C#, which shouldl run the progressBar twice. but in my VB test code, the 2nd time is fine but the 1st one will go to like 90% very fast and stay there for a while, then start the 2nd one.
What the problem could be ?
Thank you and Tony for your help.


here is the code:
[code]

Imports Autodesk.AutoCAD.Runtime
Imports CaddZone.AutoCAD.EditorServices.StatusBarProgressMeter

Public Class TestProgressMeter

#Region "StatusBarProgressMeter"

_
Public Shared Function Execute()

' setup a bogus collection to be processed,
' where we want to show the progress...

Dim count As Integer = 10000 ' size of ArrayList (and the number of
' times we call Step() when processing it).

Dim myList As New ArrayList(count)

'Dim meter1 As New CaddZone.AutoCAD.EditorServices.StatusBarProgressMeter("Populating ArrayList...", count)

Try

For i As Integer = 0 To count

myList.Add(i)
' waste some cpu cycles so we
' can see the progress meter:
Dim x As Integer = 0
For j As Integer = 0 To 100000

x = j + i
' Update progress meter
'meter1.Step()

Next

Next

Catch ex As Exception

Finally

'meter1.Dispose()

End Try

Dim meter2 As New CaddZone.AutoCAD.EditorServices.StatusBarProgressMeter("Processing ArrayList...", myList.Count)
Try

For Each n As Integer In myList

' waste some cpu cycles so we
' can see the progress meter:
Dim x As Integer = n
For j As Integer = 0 To 100000

x = j + 1

Next

' Update progress meter:
meter2.Step()

Next

Catch ex As Exception

Finally

meter2.Dispose()

End Try


End Function

#End Region

End Class

[/code]
Windows 10 64 bit, AutoCAD (ACA, Map) 2023
Message 20 of 27
Anonymous
in reply to: newArch

Hi, weslleywang!

w> I change Function to Sub, but still not work

Very strange. I' tested your's previous code (AutoCAD 2006 SP1/ VS .NET 2002) and it
work without exception on my PC.

w> I also tried another solution: use the C# version to create a dll file, create a
w> new VB.NET project with all test code inside. The VB test code is same as
w> the one in C#, which shouldl run the progressBar twice. but in my VB test
w> code, the 2nd time is fine but the 1st one will go to like 90% very fast
w> and stay there for a while, then start the 2nd one. What the problem
w> could be ?

IMHO, AutoCAD can not update progressbar, because this application is very CPU-intensive.

Best Regards,
Alexander Rivilis.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost