TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

Register
 
Be sure your post is relevant to the current discussion.  Create a new topic within the appropriate board if you are unsure.

TC with AutoIt
Read 6106 times
* August 01, 2010, 12:29:19 AM
Hi,

I have a nice idee - look at attachment.

It's that an alternate to other language?

Best wishes

PV-Profi (PS)

Logged


* August 02, 2010, 04:46:27 AM
#1
Hi Peter
Thx for the hint to AutoIT. Wikipedia helps.
I was comfortable with vba within TC.
Then I bought VB-Standard. Cheap but slowly.
Then I bought vb6 enterprise to create my own .dll
That was not really cheap, but I got it as a bargain.
The advantage: I can use all my old macros made with vba within TC.

But to spend 250 Euro for a used vb6 proffesional is not a solution for every user of TC who needs the SDK.
AutoIT is open source or free – a big advantage.

An important issue for me is  the speed.
I made the attached drawing (stored as .dwg Autocad 2000)
There are 1000 items. To change every Pencolor (from Truecolor Red to Truecolor Green)– one after the other – takes:
Running a macro within TC or as an .dll : 7 sec
Making an .exe with VB6 Standard: 12 min
That is more than 100 times slowlier!! For the most macros useless.
The vb sourcecode:

Sub Main()
Dim prop As Property
Dim i As Integer
If ActiveDrawing.Selection.Count - 1 < 9950 Or ActiveDrawing.Selection.Count - 1 > 10200 Then MsgBox "Number  items wrong    " & ActiveDrawing.Selection.Count - 1: Exit Sub
For i = 0 To ActiveDrawing.Selection.Count - 1
Set gr = ActiveDrawing.Selection.Item(i)
On Error Resume Next
For Each prop In gr.Properties("PenColor")
If gr.Properties("PenColor").Value = 255 Then gr.Properties("PenColor").Value = 65280 'change red to green
Next prop
Next i
On Error Resume Next
set gr = nothing
End Sub

It would be very helpful if you try this example with AutoIT and send the new exe.

Before running the .exe please select all items and change the color to Truecolor red

Best regards
Bernd

Logged


* August 08, 2010, 02:13:23 PM
#2
Hi Peter
I tested AutoIT

$oTC = ObjGet("","TurboCad.Application")   ; Get an existing Turbocad Object
if @error then
  Msgbox (0,"TurboCadTest","You don't have TurboCad running at this moment. Error code: " & hex(@error,8))
  exit
endif
if IsObj($oTC) then Msgbox (0,"","You successfully attached to the existing TurboCad.")
$oTC.Visible = 1      ; Let the guy show himself
Dim $prop
Dim $i
Dim $gr
If $oTC.ActiveDrawing.Selection.Count - 1 < 9950 Or $oTC.ActiveDrawing.Selection.Count - 1 > 10200 Then
   MsgBox (0, "Application-Name","Number  items wrong    " & $oTC.ActiveDrawing.Selection.Count - 1)
    Exit ;Sub
    EndIf
For $i = 0 To $oTC.ActiveDrawing.Selection.Count - 1
$gr = $oTC.ActiveDrawing.Selection.Item($i)
;On Error Resume Next
For  $prop In $gr.Properties("PenColor")
If $gr.Properties("PenColor").Value = 255 Then
   $gr.Properties("PenColor").Value = 65280 ;'change red to green the loop is working, changing the color donīt work
Else
EndIf

Next ;prop
Next ;i
$gr = 0

takes 8 minutes, so not really useful for most of my macros.

But AutoIT has some advantages using the API.

best regards
Bernd

Logged


* March 23, 2012, 01:57:48 PM
#3
Hello Programmers
I have some problems being really exited about TC19. The Internetpalett has disappeared and my 32-bit .dll (created with VB6)  will not work with TC19 - 64bit.
Ruby is disappointing. No documentation, and the Console is changed from TC18 to TC19. The small use I have in TC18 with Ruby, donīt work in TC19.
A lot of bad news. But a good one as well:
AutoIT work much better with TC.
The above post from 2010 was the result from a test on my old desktop with winXP.
Now my desktop is an Win7-64bit
Tested with AutoIT64-bit and TC19-64bit the 10000-items took 40 sec (instead of 8 minutes - see above)
Compared with the 7 sec (32-bit dll ) not an improvement, but not too bad.

best regards
Bernd
-----------------------------------------------------------------------------------------------------

Code in AutoIt

$oTC = ObjGet("","TurboCad.Application")   ; Get an existing Turbocad Object
if @error then
  Msgbox (0,"TurboCadTest","You don't have TurboCad running at this moment. Error code: " & hex(@error,8))
  exit
endif
if IsObj($oTC) then Msgbox (0,"","You successfully attached to the existing TurboCad.")
$oTC.Visible = 1      ; Let the guy show himself
Dim $prop
Dim $i
Dim $gr
If $oTC.ActiveDrawing.Selection.Count - 1 < 9950 Or $oTC.ActiveDrawing.Selection.Count - 1 > 10200 Then
   MsgBox (0, "Application-Name","Number  items wrong    " & $oTC.ActiveDrawing.Selection.Count - 1)
    Exit ;Sub
    EndIf
For $i = 0 To $oTC.ActiveDrawing.Selection.Count - 1
$gr = $oTC.ActiveDrawing.Selection.Item($i)

If $gr.Properties("PenColor").Value = 255 Then
   $gr.Properties("PenColor").Value = 65280 ;'change red to green
Else
EndIf

Next ;i
$gr = 0

« Last Edit: March 23, 2012, 02:02:46 PM by ibruethsch »

Logged