Jump to content

VBA code chang autoit


Recommended Posts

I want to convert this code to Autoit code.
I want to create a program that converts characters in an AutoCAD file.
However, I would like to ask all of you who have difficulty in change and who have good ability.
Please help me.

 

---------------------------------------------------------------------------------------------------------------------------------------------------------

Private Sub
AppActivate Application.Caption

On Error Resume Next
Dim "find text" As String
Dim "change text" As String
findtext = InputBox("insert find text : ")
changetext = InputBox("insert change text : ")
If Err Then Exit Sub
'Filtering
Dim Filterset As Object
Dim GroupCode As Variant
Dim GroupValue As Variant
Dim FilterCode(0 To 3) As Integer
Dim FilterValue(0 To 3) As Variant
FilterCode(0) = -4: FilterValue(0) = "<OR"
FilterCode(1) = 0: FilterValue(1) = "TEXT"
FilterCode(2) = 0: FilterValue(2) = "MTEXT"
FilterCode(3) = -4: FilterValue(3) = "OR>"
GroupCode = FilterCode
GroupValue = FilterValue


On Error Resume Next
If ThisDrawing.SelectionSets("TEMP") Then _
ThisDrawing.SelectionSets("TEMP").Delete
On Error GoTo 0
Set Filterset = ThisDrawing.SelectionSets.Add("TEMP")
Filterset.SelectOnScreen GroupCode, GroupValue
If Filterset.Count < 1 Then Exit Sub

Dim Change As String
Dim i As Integer
Dim TextLen As Integer
For Each FilterEnt In Filterset
FindTextLen = Len(FindText)
변경 = ""
For i = 1 To Len(FilterEnt.TextString)
If FindText = Mid(FilterEnt.TextString, i, FindTextLen) And _
Len(FilterEnt.TextString) - i + 2 > FindTextLen_
Then
Change = ChangeText + FindText
i = i + FindTextLen_ - 1
Else: Change = Change + Mid(FilterEnt.TextString, i, 1)
End If
Next i
FilterEnt.TextString = Change
FilterEnt.Update
Next FilterEnt
ThisDrawing.SelectionSets("TEMP").Delete 'delete the selection set
AppActivate Application.Caption
End Sub

---------------------------------------------------------------------------------------------------------------------------

this is my code...TT

$oAcad = ObjGet("","AutoCAD.Application")

If @error Then
    Msgbox(0,"ObjGet","Failed ")
    Exit
Endif

$ActiveDocument = $oAcad.Activedocument.Name
;~ MsgBox(0,"Name",$ActiveDocument)

$iBlocks = $oAcad.Activedocument.Blocks.Count
;~ MsgBox(0,"Count",$iBlocks)

$iConp= $oAcad.Activedocument.Blocks.item(0).count
ConsoleWrite("="&$iConp & @CRLF)

;~  $oAcad.Activedocument.Blocks.item(0).AddMText( 50, 10, "sdfgsdfsgf")

For $a = 0 to $iConp-1
ConsoleWrite($a&"="& $oAcad.Activedocument.Blocks.item(0).Mtext  & @CRLF)
Next

---------------------------

VBA Code NotRun

Edited by JLogan3o13
Link to comment
Share on other sites

Hi, Krogys

 

When using COM object manipulation you must have in mind that objects in the environment will vary a lot, and that commands and statements that may exist in VBA may wont in Au3.

 

Test your code before posting it in here, and post the errors returned by your tests.

 

Link to comment
Share on other sites

Quote

statements that may exist in VBA may wont in Au3

Not true. If you can access an object using COM then this is possible from AutoIt as well.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@krogys

Can you please give more information about the error you get? "Not working" doesn't help much ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...