Autogenerate bitmap-file from parts in Vault

Autogenerate bitmap-file from parts in Vault

Gwennberg
Advocate Advocate
266 Views
2 Replies
Message 1 of 3

Autogenerate bitmap-file from parts in Vault

Gwennberg
Advocate
Advocate

Hi
We want bitmap-file on our allready inchecked partfiles in Vault. Would it be possible to start a process there Inventor get and open the file, run a script ,(which I all ready have), close and contiue with next file. Our files are stored in folders i vault with a number serie  

BR/Goran

0 Likes
267 Views
2 Replies
Replies (2)
Message 2 of 3

Jacob__with__a__k
Enthusiast
Enthusiast

Hi,

Interesting question! here's my attempt to make it work

 

Not tested yet (no time for that currently), but hopefully you'll now have some basis to start with

The idea: you place both this rule and the script (wich I assume is a separate rule although an external rule should work as well) in a document (ipt, iam, idw doesn't matter), it will loop through all of them: open them: run the script: and close them

be sure to check out all files first! (should be possible automaticly in inventor 2024 but that's a whole different problem 😉 )

I added 2 ways to select all the documents, so choose the one you wish or add your own 😉

 

(hopefully it works lol)

I'm very interested to see your script for making a bitmap file, if you are interested in sharing it

happy coding!

 

Sub main
Dim docs As List(Of String)

'get path of all files
	docs = populatedocs1
	'docs = populatedocs2

'loop over all paths in doc
	For Each doc In docs 
		Call run_rule_in_docs(doc)
	Next

End Sub

Function populatedocs1 As List(Of String)
'adaptation of code from: https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/how-do-i-run-an-external-rule-on-all-files-in-a-folder/td-p/10496739
Dim Folder As New IO.DirectoryInfo("C:\TEMP")
For Each File As IO.FileInfo In Folder.GetFiles("*.ipt",IO.SearchOption.AllDirectories)
	If File.FullName.Contains("OldVersions") = False Then
		populatedocs1.Add(File.FullName)
	End If
Next	
End Function

Function populatedocs2 As List (Of String)
	populatedocs2.Add("C:\TEMP\doc1.ipt")
	populatedocs2.Add("C:\TEMP\doc2.ipt")
	populatedocs2.Add("C:\TEMP\doc3.ipt")
	populatedocs2.Add("C:\TEMP\doc4.ipt")
	populatedocs2.Add("C:\TEMP\doc5.ipt")
	populatedocs2.Add("C:\TEMP\doc6.ipt")
	populatedocs2.Add("C:\TEMP\doc7.ipt")
	
	Return populatedocs2
End Function

Sub run_rule_in_docs(sFilePath As String)
'adaptation of code from: https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/run-ilogic-rule-from-an-external-part-file/m-p/6026688#M61524

'name of ilogic rule
Dim oRuleName As String = "TestRule" 

'open the file invisibly
oFile =  ThisApplication.Documents.Open(sFilePath, False) 

'define the ilogicAutomation
Dim iLogicAuto As Object
iLogicAuto = iLogicVb.Automation

'get the rule
Dim oRule As Object 
oRule = iLogicAuto.GetRule(oFile, oRuleName) 

'run the rule
iLogicAuto.RunRuleDirect(oRule) 

'close the file
oFile.Close
End Sub

 

 

0 Likes
Message 3 of 3

Gwennberg
Advocate
Advocate

Thanks Jacob

The bitmap script looks like this. I have got it from this forum:

 

'-------------export BMP file -------------------------------



oPath = "\\server08\pyramid\Pyramid4\BMP\"
Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet

modeldoc = ThisDrawing.ModelDocument
		If modeldoc Is Nothing Then Exit Sub

Dim oView As DrawingView = oSheet.DrawingViews.Item(1)

oViewModelDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument

Dim oViewModelDocName As String = Left(oViewModelDoc.DisplayName, (InStrRev(oViewModelDoc.DisplayName, ".", - 1, vbTextCompare) - 1))

Dim m_Camera As Inventor.Camera
m_Camera = ThisServer.TransientObjects.CreateCamera()
If oViewModelDoc.DocumentType = kPartDocumentObject Then
  m_Camera.SceneObject = DirectCast(oViewModelDoc, PartDocument).ComponentDefinition
Else
  m_Camera.SceneObject = DirectCast(oViewModelDoc, AssemblyDocument).ComponentDefinition
End If
m_Camera.Perspective = False

Dim m_TO As Inventor.TransientObjects
m_TO = ThisApplication.TransientObjects

m_Camera.ViewOrientationType = Inventor.ViewOrientationTypeEnum.kIsoTopLeftViewOrientation
m_Camera.Fit
m_Camera.ApplyWithoutTransition
 
ThisApplication.DisplayOptions.NewWindowDisplayMode = DisplayModeEnum.kShadedWithEdgesRendering
ThisApplication.DisplayOptions.Show3DIndicator = False

Dim TumbFilename As String = oPath & oViewModelDocName & ".jpg"

m_Camera.SaveAsBitmap(TumbFilename, 800, 600, m_TO.CreateColor(255,255,255))
0 Likes