Sheet Metal Drawing automation

Sheet Metal Drawing automation

jaimin.ja.3
Enthusiast Enthusiast
566 Views
1 Reply
Message 1 of 2

Sheet Metal Drawing automation

jaimin.ja.3
Enthusiast
Enthusiast

IS THERE ANY POSSIBITY TO AUTOMATE THIS PROCESS?

  • FROM ASSEMBLY OPEN SHEETMETAL COMPONENTS ONE BY ONE
  • OPEN DRAFTING FILE ANSI.idw (PATH - "C:\Users\Public\Documents\Autodesk\Inventor 2023\Templates\en-US\Metric\ANSI (mm).idw")
  • VIEW1 = PLACE BASE VIEW (Flat Pattern (Sheet Metal View))  (Style = Hidden Line Removed)
  • VIEW2 = PLACE ISOMATRIC VIEW (Style = Hidden Line Removed)

 

  • FOR THE SCALE AND POSITION OF THIS TWO VIEW CONSIDE FOLLOWING CODE
If ActiveSheet.View("VIEW1").Height < 250 Then

        ActiveSheet.View("VIEW1").Scale = 0.6

        ActiveSheet.View("VIEW1").SetCenter(175, 222)

        ActiveSheet.View("VIEW2").SetCenter(450,262.5)

       

ElseIf ActiveSheet.View("VIEW1").Height < 500 Then

        ActiveSheet.View("VIEW1").Scale = 0.4

        ActiveSheet.View("VIEW1").SetCenter(175, 222)

        ActiveSheet.View("VIEW2").SetCenter(450,262.5)

       

ElseIf ActiveSheet.View("VIEW1").Height < 1000 Then

        ActiveSheet.View("VIEW1").Scale = 1/4.5

        ActiveSheet.View("VIEW1").SetCenter(175, 222)

        ActiveSheet.View("VIEW2").SetCenter(450,262.5)

       

End If

ActiveSheet.View("VIEW2").Scale = ActiveSheet.View("VIEW1").Scale
  • GIVE BEND ANNOTATION (FOR BEND ANNOTATION USE FOLLOWING CODE)
Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oView As DrawingView
Dim oCurve As DrawingCurve
Dim oBendNote As BendNote
Dim BendNoteCount As Integer

oDoc = ThisApplication.ActiveDocument
oSheet = oDoc.ActiveSheet
BendNoteCount = oSheet.DrawingNotes.BendNotes.Count

If BendNoteCount=0 Then
    '[add bend notes to views
	For Each oView In oSheet.DrawingViews
	 For Each oCurve In oView.DrawingCurves
	  If oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendDownEdge _
	  Or oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendUpEdge Then
		' Create the bend note
		oBendNote = oSheet.DrawingNotes.BendNotes.Add(oCurve)
	  End If
	 Next 'oCurve
	Next ']oView
	Else
	'do nothing
End If
  • SAVE IDW FILE (IF POSSIBLE, FILE NAME SHOULD BE LIKE <PART NO> & <MATERIAL> & <THIKNESS>
  • EXPORT DWG FILE WITH SAME NAME
  • EXPORT PDF FILE WITH SAME NAME

SAVE THESE FILES IN TO SAME FOLDER

 

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

JelteDeJong
Mentor
Mentor

This rule is not finished (but I'm tired.) I guess that this does most of what you are looking for. Give it a try:

Sub Main()

    Dim doc As AssemblyDocument = ThisDoc.Document

    For Each refDoc As Document In doc.AllReferencedDocuments
        If (IsSheetmetal(refDoc) = False) Then Return

        Dim drawing = CreateNewDrawing()
        Dim flatView = CreateFlatpatternView(drawing.ActiveSheet, refDoc)
        Dim isoView = CreateIsoView(drawing.ActiveSheet, refDoc)
    Next
End Sub

Public Function IsSheetmetal(doc As Document) As Boolean
    Return doc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
End Function

Public Function CreateNewDrawing() As DrawingDocument
    Dim templateFileName = "C:\Users\Public\Documents\Autodesk\Inventor 2023\Templates\en-US\Metric\ANSI (mm).idw"
    Return ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, templateFileName)
End Function

Public Function CreateFlatpatternView(sheet As Sheet, doc As Document) As DrawingView
    Dim point = CreatePoint(17.5, 22.2)

    Dim nvm = ThisApplication.TransientObjects.CreateNameValueMap()
    nvm.Add("SheetMetalFoldedModel", False)

    Dim view = sheet.DrawingViews.AddBaseView(doc, point, 1, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, "VIEW1",, nvm)

    SetScale(view)
    view.Center = point
    AddBendNotes(view)
    Return view
End Function

Public Function CreateIsoView(sheet As Sheet, doc As Document) As DrawingView
    Dim point = CreatePoint(45, 26.25)

    Dim view = sheet.DrawingViews.AddBaseView(doc, point, 1, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle, "VIEW2")

    SetScale(view)
    view.Center = point
    Return view
End Function

Public Sub SetScale(view As DrawingView)
    view.Scale = 1

    If (view.Height < 25) Then
        view.Scale = 0.6
    ElseIf (view.Height < 500) Then
        view.Scale = 0.4
    ElseIf (view.Height < 1000) Then
        view.Scale = 1 / 4.5
    End If

End Sub

Public Function CreatePoint(x As Double, y As Double)
    Return ThisApplication.TransientGeometry.CreatePoint2d(x, y)
End Function

Public Sub AddBendNotes(view As DrawingView)
    Dim sheet = view.Parent

    For Each curve In view.DrawingCurves
        If (curve.EdgeType = DrawingEdgeTypeEnum.kBendDownEdge Or
                curve.EdgeType = DrawingEdgeTypeEnum.kBendUpEdge) Then

            sheet.DrawingNotes.BendNotes.Add(curve)
        End If
    Next

End Sub

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes