14 Replies Latest reply on Mar 14, 2016 10:03 AM by Arif Akbas

    Automatic Drawing Creation with Bend Line dimentions

    Ahmed Lasheen

      Dears

      kindly i need your support , we daily create drawing for 200 parts minimum , wile process is always the same:-

       

      • Open Part.
      • Create drawing using Saved Sheet Format.
      • add flatten view with bend line and bend notes to sheet one.
      • add bend line dimension ,Bend line location dimensions as chain.
      • add another flatten view Scale 1:1 to the second sheet which has no sheet format. (without bend line, or bend line notes).

      sure API can do this steps instead of the design , but due to my limited information about API so i don't know how it can be done.

      please any help!

      such API will save a lot of time to us

       

      attached sample of created drawing

       

      Thanks

      Lasheen

        • Re: Automatic Drawing Creation with Bend Line dimentions
          Ahmed Lasheen

          any guide line will be appreciated.

          Thanks

          Lasheen

              • Re: Automatic Drawing Creation with Bend Line dimentions
                Ahmed Lasheen

                Dear Deepak

                 

                this topic helped me to start , but i still have some questions:-

                 

                -how can i add dimension between bend line automatically?

                find below steps i had finished ,"sure you will find a lot of non logic line "

                i just get copy past from several forum.

                 

                Dim swApp As SldWorks.SldWorks

                Dim swModel As SldWorks.ModelDoc2

                Dim swDraw As SldWorks.DrawingDoc

                Dim swDrawModel As SldWorks.ModelDoc2

                Dim aView As SldWorks.View

                 

                 

                Dim vConfs As Variant

                Dim i As Integer

                 

                Dim sDrTemplate As String

                Dim lDrSize As Long

                 

                Dim sOutputFolder As String

                 

                Sub main()

                   

                    Set swApp = Application.SldWorks

                   

                    Set swModel = swApp.ActiveDoc

                 

                 

                    'Output Path********

                    sOutputFolder = Left(swModel.GetPathName(), Len(swModel.GetPathName()) - Len(swModel.GetTitle()) - 7)

                    

                    'Templete***********

                    Const sDrTemplate As String = "C:\Raqtan SSF\2.Raqtan SS Library\SolidWorks Reference Files\Templates\Drawing - A4 - Rider&DXF.drwdot"

                    lDrSize = swDwgPaperSizes_e.swDwgPaperA0size

                 

                 

                           

                        Set swDraw = swApp.NewDocument(sDrTemplate, 0, 0, 0)

                       

                        Dim swView As SldWorks.View

                       

                        Set aView = swDraw.CreateFlatPatternViewFromModelView3( _

                                    swModel.GetPathName, "", 0.1485, 0.12, 0#, False, False)

                 

                 

                       

                        Dim swDrawModel As SldWorks.ModelDoc2

                        Set swDrawModel = swDraw

                              

                        swDrawModel.ForceRebuild3 False

                       

                        'swDraw.InsertModelAnnotations3 swImportModelItemsSource_e.swImportModelItemsFromEntireModel, 32776, True, True, False, False

                               

                        swDrawModel.Extension.SaveAs sOutputFolder + swModel.GetTitle() + ".slddrw", swSaveAsVersion_e.swSaveAsCurrentVersion, swSaveAsOptions_e.swSaveAsOptions_Silent, Nothing, 0, 0

                       

                        swApp.CloseDoc swDrawModel.GetTitle()

                End Sub

            • Re: Automatic Drawing Creation with Bend Line dimentions
              Peter Brinkhuis

              A macro that I made recently does the second step. I use it when I have a part/assembly open. I run the macro and it opens the existing drawing or creates a new one with a trimetic and front view. I've modified it a bit so it should work for you, I added the flat pattern. I just haven't tested it yet, that's why I left the trimetic view in there. That one should at least work when uncommented. This should get you started.

               

              If you've found a way to find out if a part is a sheet metal part, please let me know because I'm still looking for that. And look out for the custom scale/sheet scale drama, there is no command to set the view scale to "sheet scale", you can only set the sheet scale at 1:1 and do the same for each view.

              Option Explicit

              Sub main()

              Dim swApp                           As SldWorks.SldWorks

              Dim swModel                         As SldWorks.ModelDoc2               'Model/file

              Dim swDraw                          As SldWorks.DrawingDoc              'Drawing

              Dim swView                          As SldWorks.View                    'Drawing view

              Dim lStrTemplatePath                As String                           'Template path

              Dim lVarTemplateSizes               As Variant                          'Return value with template settings

              Dim lStrPartName                    As String                           'Part/drawing name

              Dim lStrPartPath                    As String                           'Part/drawing path

               

               

              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

               

               

              'Check if file is open

              If swModel Is Nothing Then

                  MsgBox ("Please open a part or assembly first.")

                  Exit Sub

              End If

              'Check if part or assembly is open

              If swModel.GetType = swDocDRAWING Then

                  MsgBox ("Please open a part or assembly first.")

                  Exit Sub

              End If

               

               

              'Get default drawing template

              lStrTemplatePath = swApp.GetUserPreferenceStringValue(swUserPreferenceStringValue_e.swDefaultTemplateDrawing)

               

              'Size dimensions of default drawing template

              lVarTemplateSizes = swApp.GetTemplateSizes(lStrTemplatePath)

              If IsEmpty(lVarTemplateSizes) Then

                  MsgBox ("Standard drawing template file is not found, check the Default Template page in the Options")

                  Exit Sub

              End If

               

               

              lStrPartPath = Left$(swModel.GetPathName, (Len(swModel.GetPathName) - 6)) & "SLDDRW"

              lStrPartName = swModel.GetTitle

               

              Set swModel = swApp.NewDocument(lStrTemplatePath, lVarTemplateSizes(0), lVarTemplateSizes(1), lVarTemplateSizes(2))

              Set swDraw = swModel

                 

              'Add trimetic view to get started.

              'Set swView = swDraw.CreateDrawViewFromModelView3(lStrPartName, "*Trimetric", (0.85 * lVarTemplateSizes(1)), (0.8 * lVarTemplateSizes(2)), 0)

               

              'Create flat pattern

              Set swView = swDraw.CreateFlatPatternViewFromModelView3(lStrPartPath, "", (0.4 * lVarTemplateSizes(1)), (0.5 * lVarTemplateSizes(2)), 0, False, False)

               

               

              'Set drawing file name/title

              swModel.SetTitle2 (lStrPartName)

               

               

              end sub

              • Re: Automatic Drawing Creation with Bend Line dimentions
                Rachayl Duker

                Hi,

                You and your organization may want to consider purchasing the add-in to Solidworks called AutoStruct. The program automatically gives a name and creates a drawing sheet for each body in your assembly including sheet metal, and the drawing sheets for the sheet metal parts have both bent views and the flat pattern including bend lines. AutoStruct also puts out a DXF 1:1 of each sheet metal part with no markings so you can do automatic laser cutting. It does other automatic documentation as well.

                You can look into it, the website is autostruct.net