Jump to content
krogys

VBA code chang autoit

Recommended Posts

krogys

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

Share this post


Link to post
Share on other sites
DynamicRookie

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.

 

Share this post


Link to post
Share on other sites
water
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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

@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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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

×