Where can I find example for controlling AutoCAD?

I am trying to migrate from excel vba to libreoffice basic. where can I find example for controlling AutoCAD?

For example I would like to generate the LibreOffice equivalent of this VBA macro:
Also, How do I set references for Autodesk libray?

Public Sub AddMyTextHeight()

Dim ACAD As AcadApplication 'Create ACAD variable of type AcadApplication
On Error Resume Next 'This tells VBA to ignore errors
Set ACAD = GetObject(, "AutoCAD.Application") 'Get a running instance of the class AutoCAD.Application

Dim textObj As AcadText

Dim insertionPoint(0 To 2) As Double
Dim height As Double

height = 0.5
xx=5
yy=7
textString="aaaa"
insertionPoint(0) = xx + 0.2
insertionPoint(1) = yy - height * 1.25
insertionPoint(2) = 0


Set textObj = ACAD.ActiveDocument.ModelSpace.AddText(textString, insertionPoint, height)
textObj.color = acBLACK
End Sub

[Edit - Opaque] - put code into preformatted text

Hi,
I have no AUTOCAD installed. I believe it is the same procedure as for the Internet Explorer ActiveX object.

It is quit easy to construct an ActiveX object:

Sub Main
oIE   = createUnoService("com.sun.star.bridge.OleObjectFactory").createInstance("InternetExplorer.Application") 
  oIE.Left   = 1
  oIE.Top    = 1
  oIE.Width  = 500
  oIE.Height = 500
  oIE.visible= 1
  oIE.Navigate("https://www.google.com")
End Sub

It is more difficult to get access to an already running instance of an ActiveX object. You have to invoke the MSScriptControl:

Sub Main
  Dim oleService 
  Dim VBScript 
  Dim s as string 
  Dim ad
  oleService = createUnoService("com.sun.star.bridge.OleObjectFactory") 
  VBScript= oleService.createInstance("MSScriptControl.ScriptControl") 
  VBScript.Language = "VBScript" 

  s = ""   
  s = s + "Public oIE()" + Chr(10)

  s = s + "set oShell = CreateObject(""Shell.Application"")" + Chr(10)
  s = s + "set oShellWindows = oShell.Windows" + Chr(10)
  s = s + "if (not oShellWindows is nothing) then" + Chr(10)     
  s = s + " ReDim oIE(oShellWindows.count-1)" + Chr(10)     
  s = s + " k = 0" + Chr(10)     
  s = s + " for each o in oShellWindows" + Chr(10)
  s = s + "  set oIE(k) = o" + Chr(10)
  s = s + "  k = k + 1" + Chr(10)
  s = s + "  next" + Chr(10)
  s = s + " end if" + Chr(10)

  VBScript.ExecuteStatement(s) 
  shellWindows = VBScript.CodeObject.oIE
 
  Dim IE 
  
  for i = 0 to UBound(shellWindows)
  	if shellWindows(i).Name = "Internet Explorer" then
      IE = shellWindows(i)
  	endif
  next i

  msgbox "found IE pointing to " + IE.LocationUrl
End Sub

Good luck,

ms777

thanks,
unfortunately the second routine failed on
line: VBScript.Language = “VBScript”
error: Basic runtime error. Object Variable not set

… please check if VBScript is empty

Please check if you have a file “C:\Windows\SysWOW64\msscript.ocx”

Then make sure you use a 32bit-Openoffice (I am on Apache 4.1.6). I am pretty sure that does not work with a 64 bit Openoffice

Good luck,

ms777