Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Harness report generation automation

Zachary.BeasonD97A7
Contributor

Harness report generation automation

Zachary.BeasonD97A7
Contributor
Contributor

I am trying to automate updating of reports in a wire harness .idw file. I can call HSL:Cable:Generate_Report just fine but I can't find any documentation on how to automate the actual generation of reports, namely specifying file save names and config files to reference. Has anyone ever done this before?

0 Likes
Reply
Accepted solutions (1)
563 Views
5 Replies
Replies (5)

A.Acheson
Mentor
Mentor

I had a quick look in the API help and there is little information on the cable and harness API 2020. 

You can use either send keys or mouse control to navigate through the dialogue box.

The below  opens the "Add files to List" dialogue  in Reports in the assembly environment. It will at least remove some tedious clicks and help navigate. 

	'https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys.send?view=net-5.0
Sub Main
   Dim oCommandMgr As CommandManager
 	oCommandMgr = ThisApplication.CommandManager
   Dim oControlDef As ControlDefinition
  	oControlDef = oCommandMgr.ControlDefinitions.Item("HSL:Cable:Generate_Report")
   Call oControlDef.Execute
   Call wait(0.6)
	System.Windows.Forms.SendKeys.SendWait("{F10}")
	System.Windows.Forms.SendKeys.SendWait("{RIGHT 2}")
	System.Windows.Forms.SendKeys.SendWait("{ENTER}")
	System.Windows.Forms.SendKeys.SendWait("{ENTER}")
	System.Windows.Forms.SendKeys.SendWait(" ")
End Sub
'https://stackoverflow.com/questions/15857893/wait-5-seconds-before-continuing-code-vb-net
   'Timer to allow time for form to come into focus.
   Private Sub wait(ByVal seconds As Integer)
     For i As Integer = 0 To seconds * 100
       System.Threading.Thread.Sleep(10)
     ' ThisApplication.DoEvents()
     Next
   End Sub

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes

Zachary.BeasonD97A7
Contributor
Contributor

I'm using VBA, not iLogic but I got it mostly running. I'm hung up on the line "System.Threading.Thread.Sleep (10)". Method or data member not found. Any advice?

0 Likes

Zachary.BeasonD97A7
Contributor
Contributor

NM, I went with Application.Wait(1) and it's working fine. This is what I have so far:

 

Public Sub ReportUpdate()
 
   Dim oCommandMgr As CommandManager
    Set oCommandMgr = ThisApplication.CommandManager
   Dim oControlDef As ControlDefinition
    Set oControlDef = oCommandMgr.ControlDefinitions.Item("HSL:Cable:Edit_Nailboard_Sketch")
     Call oControlDef.Execute
    Set oControlDef = oCommandMgr.ControlDefinitions.Item("HSL:Cable:Generate_Report")
     Call oControlDef.Execute
   'Call wait(600)
   Application.wait (1)
    
    SendKeys ("{F10}")
    SendKeys ("{RIGHT 2}")
    SendKeys ("{ENTER}")
    SendKeys ("{ENTER}")
    SendKeys (" ")
    SendKeys ("C:\Vault Local\Report Configuration Files\Connector with Color.cfg")
    SendKeys ("{ENTER}")        
End Sub

 This gets me to the point of picking the config file but I can't select the item in the list once I pick that config to change the name of the output file. No amount of keyboard basing seems to get it. Any ideas? @A.Acheson 

0 Likes

A.Acheson
Mentor
Mentor
Accepted solution

No advise really other than to hopefully find the keyboard stroke to get to you destination. It took me a while to even find the alt/F10 stroke to access the tabs. If you are really stuck you could use mouse control but I would be wary of that where accessing files are concerned. 

 

I just tested it there and to access what I assume is a vba  list box use: TAB, RIGHT 3.

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes

Zachary.BeasonD97A7
Contributor
Contributor
Yeah, that gets you into the box but I haven't found a way to change the contents other than double clicking. I feel like I'm already living dangerously by using SendKeys, I don't need to start adding mouse clicks to it as well. Thanks for the help, just wish there was documented API calls for this stuff.
0 Likes