iLogic to create image of all flat patterns in an assembly.

iLogic to create image of all flat patterns in an assembly.

ibraunLEW5D
Contributor Contributor
1,351 Views
8 Replies
Message 1 of 9

iLogic to create image of all flat patterns in an assembly.

ibraunLEW5D
Contributor
Contributor

As a preface, I am relatively new to iLogic.  I can piece together snippets from online to get them working but writing code from scratch would be a bit over my head at the time if writing this.  

 

I am looking to create 1 of 2 scenarios for flat patterns.   I currently have code that sorts through an assembly and picks out the flat patterns, creates a dxf of each and puts them in a folder that I choose.  It also creates an excel output that gives me the description, quantity, revision and material.   What I would like to create is one of 2 scenarios listed below:

 

1) The excel spreadsheet has another column with a thumbnail of the FLAT PATTERN, not the folded part.  This would be the ideal output.  The thumbnail would ideally be big enough where dimensions on the flat pattern model could be seen when printed out.  (For incoming inspection purposes rather than creating a drawing)

 

2) Another scenario that would work for us is having separate image file of the flat pattern of each part, again large enough where some basic dimensions could be legible.   

 

Has anyone done anything like this? All input welcome

0 Likes
Accepted solutions (1)
1,352 Views
8 Replies
Replies (8)
Message 2 of 9

Fouad-l
Collaborator
Collaborator

Hi @ibraunLEW5D 

This is my contribution for the first scenario:

1- Activate Flate pattern view.

https://forums.autodesk.com/t5/inventor-customization/ilogic-to-check-if-flat-pattern-view-is-active...

2- export an image of the model 

https://forums.autodesk.com/t5/inventor-customization/export-picture-png-ilogic-with-variable-name/t...

3- insert the image into excel file

https://forums.autodesk.com/t5/inventor-customization/ilogic-fun-inserting-a-jpg-into-an-excel-file/...

 

Now you need some magical hands to put all these together.

good luck!

FOUAD LATRACH - MECHANICAL ENGINEER - ELCHE - SPAIN.


Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.


ASUS ROG G703 : Windows 10 Pro - Intel i7 3.4 Ghz - 64 Gb RAM - 1.5 TB SSD - Nvidia GTX 1080 8GB.

Message 3 of 9

ibraunLEW5D
Contributor
Contributor

I am wondering if each one of those was set up as separate rules and then a fourth rule to run them one after another, not sure if that will work but I will give it a try.  Thanks for your response, I will be sure to update if I get something like this working.   

0 Likes
Message 4 of 9

marcin_otręba
Advisor
Advisor

Hi,

 

this one will export flat pattern to image in the same folder as file is:

If you use ilogic to export to dxf you can place export(doc) after export command and copy paste export sub.

 

Sub main
	Dim ass As AssemblyDocument = ThisDoc.Document
	Dim doc As Document
	For Each doc In ass.AllReferencedDocuments
	If doc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then 
	
	export(doc)	

	End If
	Next
End Sub

Sub export(doc As Document)
	doc=ThisApplication.Documents.Open(doc.FullFileName,True)
	Dim sh As SheetMetalComponentDefinition = doc.componentdefinition
	Dim fp As FlatPattern
	If sh.HasFlatPattern = False
		sh.Unfold
	End If	
		fp= sh.FlatPattern
		fp.Edit()
		doc.selectset.select(fp.TopFace)
		ThisApplication.CommandManager.ControlDefinitions.Item("AppLookAtCmd").Execute
		doc.selectset.clear
	Dim m_Camera As Inventor.Camera
	m_Camera = ThisApplication.ActiveView.Camera
   'm_Camera.SceneObject = fp

Dim m_TO As Inventor.TransientObjects
m_TO = ThisApplication.TransientObjects
 
Dim oFileName As String = doc.fullfilename
m_Camera.Fit
m_Camera.ApplyWithoutTransition

Try

m_Camera.SaveAsBitmap(Replace( oFileName,".ipt", ".bmp"), 2970, 2100)
Catch
End Try doc.Close(True) End Sub

then you need to use it with you export rule.

if you need more help give me know.

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 5 of 9

marcin_otręba
Advisor
Advisor

also consider export of flat pattern extend to your excel, then you will have flat pattern outer box dimmensions to inspect it.

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 6 of 9

ibraunLEW5D
Contributor
Contributor

This actually works very well, thank you for this.  Do  you know if there is a way to point all the files to save in a particular folder?  This might be getting too far into the weeds here but is there also a way to change the background to white for the image and then return back to normal after the image is done? 

 

Thank you again that code you sent works great

0 Likes
Message 7 of 9

marcin_otręba
Advisor
Advisor
Accepted solution
Sub main
	Dim folder As String = "C:\EXPORT\"
	If Dir(folder) = "" Then
		System.IO.Directory.CreateDirectory(folder)
	End If
	Dim ass As AssemblyDocument = ThisDoc.Document
	Dim doc As Document
	For Each doc In ass.AllReferencedDocuments
	If doc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then 

	export(doc, folder)	

	End If
	Next
End Sub

Sub export(doc As Document, folder As String)
	doc=ThisApplication.Documents.Open(doc.FullFileName,True)
	Dim sh As SheetMetalComponentDefinition = doc.componentdefinition
	Dim fp As FlatPattern
	If sh.HasFlatPattern = False
		sh.Unfold
	End If	
		fp= sh.FlatPattern
		fp.Edit()
		doc.selectset.select(fp.TopFace)
		ThisApplication.CommandManager.ControlDefinitions.Item("AppLookAtCmd").Execute
		doc.selectset.clear
	Dim m_Camera As Inventor.Camera
	m_Camera = ThisApplication.ActiveView.Camera
   'm_Camera.SceneObject = fp
ThisApplication.DisplayOptions.Show3DIndicator = False

 
Dim oFileName As String = Trim(Mid(doc.FullFileName, InStrRev(doc.FullFileName, "\", -1) + 1, Len(doc.FullFileName) - InStrRev(doc.FullFileName, "\", -1) - 4))
m_Camera.Fit
m_Camera.ApplyWithoutTransition

Try

m_Camera.SaveAsBitmap( folder &  oFileName & ".bmp", 2970, 2100,ThisApplication.TransientObjects.CreateColor(255,255,255), ThisApplication.TransientObjects.CreateColor(255,255,255))
Catch
End Try
ThisApplication.DisplayOptions.Show3DIndicator = True
doc.Close(True)
End Sub

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 8 of 9

ibraunLEW5D
Contributor
Contributor

This works amazing, thank you! 

0 Likes
Message 9 of 9

Anonymous
Not applicable

Thanks But  How can I add  to excel that export images ?

in addition  how can ı export 3d png image in assembly with the rule ?

 
0 Likes