iLogic - place sheet metal on drawing

iLogic - place sheet metal on drawing

Anonymous
Not applicable
973 Views
1 Reply
Message 1 of 2

iLogic - place sheet metal on drawing

Anonymous
Not applicable

Hello,

 

I already have a code that allows me to place individual parts onto a .idw. I want to extend the usage of it and therefore I'd like to place multiple sheet metal parts out of a assembly onto the drawing. Each part on a new sheet. Folded parts should be unfolded and then placed. Maybe even in order according to the BOM.

 

Is it possible to tell Inventor, that the parts should always be in, for example, top-view? I think they are on the flat sourface already, when unfolded. With my code I had the issue, that sometimes parts are build on a different plane and I have to correct it. 

 

Some parts we order folded, because our in house machines can't do it. Is there a way to mark them as laser+fold? Maybe you can put both views onto it's sheet at once. Wouln't be a big deal if this doesn't work. 

 

Then, when on the drawing - can you auto scale all sheets? That way I only need to add dimensions/ comments and can order my parts. 

 

Maybe I just want a little too much, but here's the code I already have 😀

 

Private Sub Main()
	'assume your laser part document is open and active
	
	If ThisApplication.Documents.Count=0 OrElse Not ThisApplication.ActiveDocumentType = DocumentTypeEnum.kPartDocumentObject Then
		MsgBox("This rule can only start with an part document active.", , "iLogic")
		Exit Sub
	End If
		
	Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument

	Dim oDrawdoc As DrawingDocument = GetDrawing	
	
	If oDrawdoc Is Nothing Then
		MsgBox("Something went wrong getting selected drawing.", , "iLogic")
		Exit Sub
	End If
	
	'Call the rule with the drawing view creation
	Call CreateDrawingView(oDrawdoc, oPartDoc)
	
	MsgBox("Done",,"iLogic")
End Sub

Private Function GetDrawing() As DrawingDocument

Dim oFileDlg As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
oFileDlg.Filter="Autodesk Inventor-Drawing (*.idw)|*.idw|All Files (*.*)|*.*"
oFileDlg.FilterIndex = 1
oFileDlg.DialogTitle = "Open Laser Part Drawing"
oFileDlg.CancelError = True
On Error Resume Next
Err.Clear 
	oFileDlg.ShowOpen()
If Not Err.Number = 0 Then
	Return Nothing
End If

Dim oDoc As Document
For Each oDoc In ThisApplication.Documents
	If oDoc.FullFileName = oFileDlg.FileName Then
		GetDrawing =oDoc
		Return GetDrawing
	End If
Next

GetDrawing=ThisApplication.Documents.Open(oFileDlg.FileName)

End Function


Private Sub CreateDrawingView(ByVal oDrawDoc As DrawingDocument, ByVal oPartDoc As PartDocument)
	
	Dim oActiveSheet As Sheet = oDrawDoc.ActiveSheet
	Dim oSheetSize As DrawingSheetSizeEnum = oActiveSheet.Size
	Dim oOrientation As PageOrientationTypeEnum = oActiveSheet.Orientation
	Dim sSheetName As String= System.IO.Path.GetFileNameWithoutExtension(oPartDoc.FullFileName)
	Dim oWidth As Object = oActiveSheet.Width
	Dim oHeight As Object=oActiveSheet.Height
	
	Dim oSheet As Sheet = oDrawDoc.Sheets.Add(oSheetSize, oOrientation, sSheetName, oWidth, oHeight)
	oSheet.AddTitleBlock(oActiveSheet.TitleBlock.Definition)
	oSheet.AddBorder("Brennteil Rahmen")
	
	oSheet.Activate
	Dim oPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width/2, oSheet.Height/2)
	
	oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint,1,ViewOrientationTypeEnum.kFrontViewOrientation,DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle )

End Sub

Greets Daniel

0 Likes
974 Views
1 Reply
Reply (1)
Message 2 of 2

A.Acheson
Mentor
Mentor

All of your post requests are possible with enough research on this forum and piecing  together parts of rules. The below is just a starter for you.  Haven’t actually made up a workflow as you described but if your happy to start putting together some code I am sure forum user would be happy to advise with any issues you have.

 

Step1: Loop through the assembly document and search/ filter for the files you need. The link in the last post has a rule for use in ilogic to do this. The one above it has VBA rule.

 

https://forums.autodesk.com/t5/inventor-customization/run-sheet-metal-rule-from-assembly-document/td...

 

Replacing this snippet

Dim rule As Object

rule = auto.GetRule(oRefDoc, ruleName)

'If (rule Is Nothing) Then'Call MsgBox("No rule named " & ruleName & " was found in the document.")'Else'MessageBox.Show(rule.Name, oRefdoc.displayname)

 

Dim i As Integer

i = auto.RunRuleDirect(rule)

with MessageBox.Show(oRefdoc.displayname)

 

Should return all docs with sheetmetal parts.

Using this you can then call your drawing rule to create drawing views.

 

Step 2 Drawing Rule:

Are you placing all parts in one drawing on several sheets? Or all in separate drawings? The first is a little more complicated than the second but both are possible.

 

All the other items can be addressed once you start working on step 1 and 2. There may even be a more complete rule on this forum which would be the first place I would 👀 

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