Edit iLogic

Edit iLogic

kresh.bell
Collaborator Collaborator
298 Views
3 Replies
Message 1 of 4

Edit iLogic

kresh.bell
Collaborator
Collaborator

I have iLogic which works perfect.

Is it possible?
1) add options, when I run iLogic, first open window with message "Please check ....." with two button. "Ok" and "Cancel". If I click "Ok" iLogic continiusly work, if I click "Cancel" iLogic aboort.
2) add image in this windows

Sub Main
	
	Dim fileDlg As Inventor.FileDialog = Nothing
	InventorVb.Application.CreateFileDialog(fileDlg)

	fileDlg.Filter = "Spredsheet Files (*.xls) (*.xlsx) (*.xlsm) (*.xlsb)|*.xls; *.xlsx; *.xlsm; *.xlsb"

	'Set open location using one of these 2 options below, "1)Hard coded" or "2)Project location":
	'fileDlg.InitialDirectory = "D:\INVENTOR DATA\PROJEKTI\"  'Hard Coded path:
	fileDlg.InitialDirectory = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath

	'Show File Open Dialogue
	fileDlg.DialogTitle = "Browse for XLS File"
	fileDlg.ShowOpen()
	
	Dim xlFile As String  = fileDlg.FileName
	If xlFile = "" Then : Exit Sub: End If

	'Open Excel file.
	GoExcel.Open(xlFile, "Job Sheet")

	Dim doc As Document = ThisDoc.Document
	Dim trans As Transaction = ThisApplication.TransactionManager.StartTransaction(doc, "Custom Properties Import") 'Make this a single transaction
	Dim filename As String  = Nothing
	
	processDocument(filename,xlFile)
	
	If doc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then 
		
		'Traverse all referenced documents.
		For Each refDoc As Document In doc.AllReferencedDocuments 
			
			'Avoid readonly files like CC and Library.
			If refDoc.IsModifiable Then
				filename = IO.Path.GetFileName(refDoc.FullFileName)
				processDocument(filename,xlFile)
			End If
			
		Next
	End If
	
	'Close Excel file.
	GoExcel.Close
	
	trans.End 'End the trasaction
	
	MessageBox.Show("Job Sheet Successfully Imported", "iLogic")

End Sub

Sub processDocument(filename As String, xlFile As String)

	'Read from Excel file
	iProperties.Value(filename,"Custom", "Referenced Spreadsheet File Name") = xlFile
	iProperties.Value(filename,"Custom", "AreaCode") = GoExcel.CellValue("H4")
	iProperties.Value(filename,"Custom", "AreaName") = GoExcel.CellValue("C4")
	iProperties.Value(filename,"Custom", "ComponentCode") = GoExcel.CellValue("H7")
	iProperties.Value(filename,"Custom", "ComponentName") = GoExcel.CellValue("C7")
	iProperties.Value(filename,"Custom", "Priority") = GoExcel.CellValue("P7")
	iProperties.Value(filename,"Custom", "D365WoNumber") = GoExcel.CellValue("H8")
	iProperties.Value(filename,"Custom", "DWGName") = GoExcel.CellValue("C6")
	iProperties.Value(filename,"Custom", "DWGRef") = GoExcel.CellValue("H6")
	iProperties.Value(filename,"Custom", "FSCReg") = GoExcel.CellValue("N20")
	iProperties.Value(filename,"Custom", "HealthSafetySheets") = GoExcel.CellValue("H19")
	iProperties.Value(filename,"Custom", "IssuedTo") = GoExcel.CellValue("P6")
	iProperties.Value(filename,"Custom", "ItemCode") = GoExcel.CellValue("H5")
	iProperties.Value(filename,"Custom", "ItemName") = GoExcel.CellValue("C5")
	iProperties.Value(filename,"Custom", "JobDescription") = GoExcel.CellValue("A9")
	iProperties.Value(filename,"Custom", "LoadList") = GoExcel.CellValue("C20")
	iProperties.Value(filename,"Custom", "Notes01") = GoExcel.CellValue("A10")
	iProperties.Value(filename,"Custom", "Notes02") = GoExcel.CellValue("A11")
	iProperties.Value(filename,"Custom", "Notes03") = GoExcel.CellValue("A12")
	iProperties.Value(filename,"Custom", "Notes04") = GoExcel.CellValue("A13")
	iProperties.Value(filename,"Custom", "Notes05") = GoExcel.CellValue("A14")
	iProperties.Value(filename,"Custom", "Notes06") = GoExcel.CellValue("A15")
	iProperties.Value(filename,"Custom", "Notes07") = GoExcel.CellValue("A16")
	iProperties.Value(filename,"Custom", "Notes08") = GoExcel.CellValue("A17")
	iProperties.Value(filename,"Custom", "Notes09") = GoExcel.CellValue("A18")
	iProperties.Value(filename,"Custom", "ProjectCode") = GoExcel.CellValue("H3")
	iProperties.Value(filename,"Custom", "Project_Name") = GoExcel.CellValue("C3")
	iProperties.Value(filename,"Custom", "RefDrawing") = GoExcel.CellValue("C6")
	iProperties.Value(filename,"Custom", "TehnicalDataSheets") = GoExcel.CellValue("P19")
	iProperties.Value(filename,"Custom", "LoadList") = GoExcel.CellValue("C20")
	iProperties.Value(filename,"Custom", "UnitQty1") = GoExcel.CellValue("A22")
	iProperties.Value(filename,"Custom", "UnitQty2") = GoExcel.CellValue("A23")
	iProperties.Value(filename,"Custom", "UnitQty3") = GoExcel.CellValue("A24")
	iProperties.Value(filename,"Custom", "UnitName1") = GoExcel.CellValue("B22")
	iProperties.Value(filename,"Custom", "UnitName2") = GoExcel.CellValue("B23")
	iProperties.Value(filename,"Custom", "UnitName3") = GoExcel.CellValue("B24")
	iProperties.Value(filename,"Custom", "UnitEmpty1") = GoExcel.CellValue("C22")
	iProperties.Value(filename,"Custom", "UnitEmpty2") = GoExcel.CellValue("C23")
	iProperties.Value(filename,"Custom", "UnitEmpty3") = GoExcel.CellValue("C24")
	iProperties.Value(filename,"Custom", "UnitDescription1") = GoExcel.CellValue("D22")
	iProperties.Value(filename,"Custom", "UnitDescription2") = GoExcel.CellValue("D23")
	iProperties.Value(filename,"Custom", "UnitDescription3") = GoExcel.CellValue("D24")

End Sub

 

0 Likes
Accepted solutions (2)
299 Views
3 Replies
Replies (3)
Message 2 of 4

bob_clark5J5M8
Contributor
Contributor
Accepted solution

for q1 you can do something like what is shown below and place it at the start of the code.

for q2, its not possible on a message window.

question = MessageBox.Show("Please check........." , "iLogic",MessageBoxButtons.OKCancel,MessageBoxIcon.Information)  

        If question = vbCancel Then                                    

Return
                                       
End If

 

0 Likes
Message 3 of 4

kresh.bell
Collaborator
Collaborator

Thanks, it works!!!

 

One more question. Is it possible change visual style message box? E.g. dark

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Hi @kresh.bell.  I think that is a question that we all ask at one point or another, when we really get into writing iLogic rules, and maybe have not used much vb.net before (or maybe not for a long time).  I even created an idea in the Inventor Ideas forum about it back in 2019 about this just before I figured that one out for myself.  Unfortunately, the answer is no, so that idea will never be implemented (not possible for them to implement it).  We can not do much with the formatting of a MsgBox dialog or MessageBox.Show dialog from an iLogic rule.  Those are part of the .net coding system (System.Windows.Forms.Messagebox ), rather than something controlled by Autodesk.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)