Drawing automation of Sheetmetal components

Drawing automation of Sheetmetal components

jaimin.ja.3
Enthusiast Enthusiast
1,056 Views
6 Replies
Message 1 of 7

Drawing automation of Sheetmetal components

jaimin.ja.3
Enthusiast
Enthusiast

I want to automate this process by using Vba or Ilogic code can some one give me solution to this repetitive task automation ?

Here are the steps that i do manually.

1. Open Sheetmetal part from assembly.

2. Create Flat Pattern 3. Open ANSI.idw File (drafting file)

3. Place Flat view

4. Give Bend Notes (Annotate > Feature Notes > Bend)

5. Place Isometric view for reference of same scale as flat pattern

6. Change the layer of bend notes and bend line to Marking (Marking layer is created already just need to select the lines then i go to Annotate > Format > Select Marking)

7. save file (in same folder)8. Export pdf file

8. Export to Dwg file.

9. Close the .idw file and Sheetmetal component 10. repeat for other component of assembly (for each and every Sheetmetal components.

0 Likes
1,057 Views
6 Replies
Replies (6)
Message 2 of 7

al.popovich
Contributor
Contributor

We recently had our vendor programmers automate our sheet metal drawings. It is a very difficult task but they have accomplished it.

Message 3 of 7

jaimin.ja.3
Enthusiast
Enthusiast
That's great to hear that the vendor programmers were able to successfully automate the sheet metal drawing process. It sounds like this will be a helpful tool for saving time and reducing errors in the future.

Out of curiosity, how did the vendor programmers automate the sheet metal drawing process? Did they provide iLogic and VBA code, or did they develop a plugin or other software tool?
0 Likes
Message 4 of 7

JelteDeJong
Mentor
Mentor

This is not perfect but I guess it's a good start. You will need to change some stuff where I added comments

Sub Main()
    Dim doc As AssemblyDocument = ThisDoc.Document
    Dim def As AssemblyComponentDefinition = doc.ComponentDefinition
    For Each refDoc As Document In doc.AllReferencedDocuments
        If (refDoc.DocumentType <> DocumentTypeEnum.kPartDocumentObject) Then Continue For
        If (refDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") Then Continue For

        DoStuffToSheetmetalPart(refDoc)
    Next
End Sub

Private Sub DoStuffToSheetmetalPart(modelDoc As Document)

    ' Set your templateFileName
    Dim templateFileName = ""
    Dim drawingDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, templateFileName)

    Dim sheet As Sheet = drawingDoc.ActiveSheet

    Dim view As DrawingView = CreateBaseFlatPatternView(sheet, modelDoc)
    AddBendNotes(view)
    CreateIsoView(sheet, modelDoc)

    Dim name = System.IO.Path.ChangeExtension(modelDoc.FullDocumentName, ".idw")
    drawingDoc.SaveAs(name, True)

    name = System.IO.Path.ChangeExtension(modelDoc.FullDocumentName, ".pdf")
    drawingDoc.SaveAs(name, True)

    name = System.IO.Path.ChangeExtension(modelDoc.FullDocumentName, ".dwg")
    drawingDoc.SaveAs(name, True)

    drawingDoc.Close(True)
End Sub

Private Function GetModelDocument(modelDocName As String)
    Dim modelDoc As Document = ThisApplication.Documents.Open(modelDocName)
    Dim oSMDef As SheetMetalComponentDefinition = modelDoc.ComponentDefinition
    If oSMDef.HasFlatPattern = False Then
        oSMDef.Unfold()
        oSMDef.FlatPattern.ExitEdit()
    End If

    Return modelDoc
End Function



Private Sub AddBendNotes(view As DrawingView)

    Dim bendCurves = view.DrawingCurves.Cast(Of DrawingCurve).
        Where(Function(curve) curve.EdgeType = DrawingEdgeTypeEnum.kBendDownEdge Or
                                curve.EdgeType = DrawingEdgeTypeEnum.kBendUpEdge).ToList()

    Dim layers As LayersEnumerator = view.Parent.Parent.StylesManager.Layers

    ' change to your own layer
    Dim layer As Layer = layers.Item("Hatch (ANSI)")

    Dim bendNotes = view.Parent.DrawingNotes.BendNotes
    For Each curve As DrawingCurve In bendCurves
        Dim note = bendNotes.Add(curve)
        note.Layer = layer


        For Each segment As DrawingCurveSegment In curve.Segments
            segment.Layer = layer
        Next

    Next
End Sub

Private Function CreateBaseFlatPatternView(sheet As Sheet, modelDoc As Document)
    Dim oBaseViewOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
    oBaseViewOptions.Add("SheetMetalFoldedModel", False)


    ' Change view position here
    Dim position As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(10, 10)
    ' change scale here
    Dim scale As Double = 0.5

    Dim view As DrawingView = sheet.DrawingViews.AddBaseView(modelDoc, position,
                    scale,
                    ViewOrientationTypeEnum.kFrontViewOrientation,
                    DrawingViewStyleEnum.kShadedDrawingViewStyle,,,
                    oBaseViewOptions)
    Return view
End Function
Private Function CreateIsoView(sheet As Sheet, modelDoc As Document)


    ' Change view position here
    Dim position As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(20, 20)
    ' change scale here
    Dim scale As Double = 0.5

    Dim view As DrawingView = sheet.DrawingViews.AddBaseView(modelDoc, position,
                    scale,
                    ViewOrientationTypeEnum.kIsoTopLeftViewOrientation,
                    DrawingViewStyleEnum.kShadedDrawingViewStyle)
    Return view
End Function

 

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

Message 5 of 7

al.popovich
Contributor
Contributor
Good morning,
All the programming was done with iLogic/VB.

There were many challenges that we worked through, as drawings are seemingly the most difficult to automate.

The level of coding is well beyond my capabilities so unfortunately I can't offer much technical assistance.

Best of luck in your journey.
Message 6 of 7

jaimin.ja.3
Enthusiast
Enthusiast
it works perfectly but i still need some changes in that code here is the topics it upgrades in that code then it will work perfectly.
• It creates shaded view please change shaded view to "Hidden Line Remove View".
• Drawing template (need title block) plese use ANSI.idw File as a template here is the path of that file "C:\Users\Public\Documents\Autodesk\Inventor 2023\Templates\en-US\Metric\ANSI (mm).idw"
• Is that possible to add conditions for scale of both view (Flat and Isometric) like
If view Height (flat file) < 250 Then
Scale = 1/1.5
Else if view Height (flat file) < 500 Then
Scale = 1/2
Else if view Height (flat file) < 1000 Then
Scale = 1/3
Else if view Height (flat file) > 1000 Then
Scale = 1/8
0 Likes
Message 7 of 7

jaimin.ja.3
Enthusiast
Enthusiast

can you share the code ?

 

0 Likes