Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inventor iRule stopped working after switch from 2023 to 2025 (I think)

1 REPLY 1
Reply
Message 1 of 2
jeaglesonNEUHG
172 Views, 1 Reply

Inventor iRule stopped working after switch from 2023 to 2025 (I think)

jeaglesonNEUHG
Participant
Participant

Hello All,

I have used an iRule successfully in the past to read values from an Excel Spreadsheet (sheet "MASTER_DB"), input the parameters into the Part, update the Drawing, and then Save the Drawing as a DXF. It runs through about 66 of rows of data, before coming to a Blank Row, which then terminates the loop.

 

It was working about 2 months ago. When I tried to run it today, I've been given 2 different errors. When I run it first, I get the "Line 50 Error". If I run it again, I get the Line "36 Error." This repeats indefinitely. The only thing (I think) that I've changed is updated Inventor 2023 to Inventor 2025.

 

'Known Parameters
Dim FolderName As String = "G:\Shared drives\E Myatt\000-Standard Parts\STANDARD CAD\MYATT_HH_MASTER_V1\"
Dim PartName As String = "TOP_PLATE.ipt"
Dim DrawingName As String = "TOP_PLATE.idw"
Dim sfile As String = "G:\Shared drives\E Myatt\000-Standard Parts\STANDARD CAD\MYATT_HH_MASTER_V1\MYATT_HH_MASTER_DB_V1.xlsx"
Dim OutputLocation As String = "G:\Shared drives\E Myatt\000-Standard Parts\STANDARD CAD\MYATT_HH_MASTER_V1\OUTPUTS\TOP_PLATE" 'Set for each Part Name
Dim oMSName As String = "TYPE_C" 
Dim currentRow As Integer = 147 'Refer to MASTER_DB

'Variable Parameters
Dim PartDoc As PartDocument
Dim DrawDoc As DrawingDocument
Dim inventorApp As Inventor.Application
Dim oIDWFile As Inventor.DrawingDocument
Dim oSheet As Inventor.Sheet
Dim oDrawingView As Inventor.DrawingView


'Open IDW File 
Call ThisApplication.Documents.Open(FolderName + DrawingName)
oIDWFile = ThisApplication.ActiveDocument

'Loop to Set View1 to TYPE_C
	For Each oDrawingView In oIDWFile.ActiveSheet.DrawingViews
		If oDrawingView.ActiveModelState <> oMSName Then
			Logger.Info(oDrawingView.Label.Text & " " & oDrawingView.ActiveModelState)
			oDrawingView.SetActiveModelState(oMSName, True, True)
		End If
		'oSheet.Update
		oIDWFile.Update
	Next
	

'STEP 2: Point to proper Excel Spreadsheet

GoExcel.Open(sfile, "MASTER_DB")

 ' Open Part file
    'ThisDoc.Launch("TOP_PLATE.ipt")
	Call ThisApplication.Documents.Open(FolderName + PartName)
	PartDoc = ThisApplication.ActiveDocument
	
	'Set to Model State
	ThisDoc.ActiveModelState = oMSName

'STEP 3: Update the part for all values in teh rows of the Excel Sheet and Export Drawing as DXF.
' Initialize row counter


Do While GoExcel.CellValue("T" & currentRow) <> ""
    ' Open Part file
    'ThisDoc.Launch("TOP_PLATE.ipt")
	Call ThisApplication.Documents.Open(FolderName + PartName)
	PartDoc = ThisApplication.ActiveDocument
	
	'Set to Model State
	ThisDoc.ActiveModelState = oMSName

   ' Read values from Cells
    TP_PN = GoExcel.CellValue("T" & currentRow)
	TP_THK = GoExcel.CellValue("U" & currentRow)
    TP_MAIN_DIA = GoExcel.CellValue("V" & currentRow)
    TP_GR_HOLE_DIA = GoExcel.CellValue("X" & currentRow)
	TP_MNT_HOLE_PITCH_DIA = GoExcel.CellValue("Y" & currentRow)
	TP_MNT_HOLE_AMT = GoExcel.CellValue("Z" & currentRow)
	TYPE_A_TP_CTR_HOLE_DIA = GoExcel.CellValue("AA" & currentRow)
	TYPE_D_E_CTR_HOLE_DIA = GoExcel.CellValue("AB" & currentRow)

	'force an update when your rule has finished running
	RuleParametersOutput()
	InventorVb.DocumentUpdate()
	
'Switch to Drawing File:
'Call ThisApplication.Documents.Open(ThisDoc.PathAndFileName(False) + ".idw")
Call ThisApplication.Documents.Open(FolderName + DrawingName)
oIDWFile = ThisApplication.ActiveDocument


'DrawDoc = ThisApplication.Documents.Open(ThisDoc.PathAndFileName(False) + ".idw")
'oDrawingView = "VIEW1"
'oDrawingView.SetActiveModelState("TYPE_A", True, True)
	
	
    oDocument = ThisApplication.ActiveDocument
    oDocument.SaveAs(OutputLocation & "\" & TP_PN & "_TOP_PLATE_" & TP_THK & "_THK" & ".dxf", True) ' For DXF's
    
	currentRow = currentRow + 1
	
Loop

 

jeaglesonNEUHG_2-1719682637488.png

 

jeaglesonNEUHG_3-1719682759789.pngjeaglesonNEUHG_4-1719682798755.png

 

Can anyone spot anything obvious? I'm no pro with coding, so I'm sure it's sloppy. But I swear, it used to work!
Thank you in advance.

-Jeff

 

 

0 Likes

Inventor iRule stopped working after switch from 2023 to 2025 (I think)

Hello All,

I have used an iRule successfully in the past to read values from an Excel Spreadsheet (sheet "MASTER_DB"), input the parameters into the Part, update the Drawing, and then Save the Drawing as a DXF. It runs through about 66 of rows of data, before coming to a Blank Row, which then terminates the loop.

 

It was working about 2 months ago. When I tried to run it today, I've been given 2 different errors. When I run it first, I get the "Line 50 Error". If I run it again, I get the Line "36 Error." This repeats indefinitely. The only thing (I think) that I've changed is updated Inventor 2023 to Inventor 2025.

 

'Known Parameters
Dim FolderName As String = "G:\Shared drives\E Myatt\000-Standard Parts\STANDARD CAD\MYATT_HH_MASTER_V1\"
Dim PartName As String = "TOP_PLATE.ipt"
Dim DrawingName As String = "TOP_PLATE.idw"
Dim sfile As String = "G:\Shared drives\E Myatt\000-Standard Parts\STANDARD CAD\MYATT_HH_MASTER_V1\MYATT_HH_MASTER_DB_V1.xlsx"
Dim OutputLocation As String = "G:\Shared drives\E Myatt\000-Standard Parts\STANDARD CAD\MYATT_HH_MASTER_V1\OUTPUTS\TOP_PLATE" 'Set for each Part Name
Dim oMSName As String = "TYPE_C" 
Dim currentRow As Integer = 147 'Refer to MASTER_DB

'Variable Parameters
Dim PartDoc As PartDocument
Dim DrawDoc As DrawingDocument
Dim inventorApp As Inventor.Application
Dim oIDWFile As Inventor.DrawingDocument
Dim oSheet As Inventor.Sheet
Dim oDrawingView As Inventor.DrawingView


'Open IDW File 
Call ThisApplication.Documents.Open(FolderName + DrawingName)
oIDWFile = ThisApplication.ActiveDocument

'Loop to Set View1 to TYPE_C
	For Each oDrawingView In oIDWFile.ActiveSheet.DrawingViews
		If oDrawingView.ActiveModelState <> oMSName Then
			Logger.Info(oDrawingView.Label.Text & " " & oDrawingView.ActiveModelState)
			oDrawingView.SetActiveModelState(oMSName, True, True)
		End If
		'oSheet.Update
		oIDWFile.Update
	Next
	

'STEP 2: Point to proper Excel Spreadsheet

GoExcel.Open(sfile, "MASTER_DB")

 ' Open Part file
    'ThisDoc.Launch("TOP_PLATE.ipt")
	Call ThisApplication.Documents.Open(FolderName + PartName)
	PartDoc = ThisApplication.ActiveDocument
	
	'Set to Model State
	ThisDoc.ActiveModelState = oMSName

'STEP 3: Update the part for all values in teh rows of the Excel Sheet and Export Drawing as DXF.
' Initialize row counter


Do While GoExcel.CellValue("T" & currentRow) <> ""
    ' Open Part file
    'ThisDoc.Launch("TOP_PLATE.ipt")
	Call ThisApplication.Documents.Open(FolderName + PartName)
	PartDoc = ThisApplication.ActiveDocument
	
	'Set to Model State
	ThisDoc.ActiveModelState = oMSName

   ' Read values from Cells
    TP_PN = GoExcel.CellValue("T" & currentRow)
	TP_THK = GoExcel.CellValue("U" & currentRow)
    TP_MAIN_DIA = GoExcel.CellValue("V" & currentRow)
    TP_GR_HOLE_DIA = GoExcel.CellValue("X" & currentRow)
	TP_MNT_HOLE_PITCH_DIA = GoExcel.CellValue("Y" & currentRow)
	TP_MNT_HOLE_AMT = GoExcel.CellValue("Z" & currentRow)
	TYPE_A_TP_CTR_HOLE_DIA = GoExcel.CellValue("AA" & currentRow)
	TYPE_D_E_CTR_HOLE_DIA = GoExcel.CellValue("AB" & currentRow)

	'force an update when your rule has finished running
	RuleParametersOutput()
	InventorVb.DocumentUpdate()
	
'Switch to Drawing File:
'Call ThisApplication.Documents.Open(ThisDoc.PathAndFileName(False) + ".idw")
Call ThisApplication.Documents.Open(FolderName + DrawingName)
oIDWFile = ThisApplication.ActiveDocument


'DrawDoc = ThisApplication.Documents.Open(ThisDoc.PathAndFileName(False) + ".idw")
'oDrawingView = "VIEW1"
'oDrawingView.SetActiveModelState("TYPE_A", True, True)
	
	
    oDocument = ThisApplication.ActiveDocument
    oDocument.SaveAs(OutputLocation & "\" & TP_PN & "_TOP_PLATE_" & TP_THK & "_THK" & ".dxf", True) ' For DXF's
    
	currentRow = currentRow + 1
	
Loop

 

jeaglesonNEUHG_2-1719682637488.png

 

jeaglesonNEUHG_3-1719682759789.pngjeaglesonNEUHG_4-1719682798755.png

 

Can anyone spot anything obvious? I'm no pro with coding, so I'm sure it's sloppy. But I swear, it used to work!
Thank you in advance.

-Jeff

 

 

Tags (4)
Labels (2)
1 REPLY 1
Message 2 of 2

jeaglesonNEUHG
Participant
Participant

Solved. My Excel Spreadsheet had changed from a .xlsx to .xlsm.

Solved. My Excel Spreadsheet had changed from a .xlsx to .xlsm.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report