5 6 7 8 9 10 141 Replies Latest reply on Dec 6, 2018 6:27 AM by Ulric Bloem Go to original post
      • 90. Re: Batch export to dwg
        Stephen Muir

        Are there any specific syntax requirements for the Map File path?

        Or am i mistaken on the Code that represents the saveas operation?


        Sorry i dont have much VB experience and this is my first In SW




                    Dim strDxfDefMap As String


                strDxfDefMap = "C:\Users\********\Desktop\BEND LINES"  'Enter path to your DXF map here


                swApp.SetUserPreferenceToggle swDxfMapping, True

                swApp.SetUserPreferenceToggle swDXFDontShowMap, True

                swApp.SetUserPreferenceIntegerValue swDxfMappingFileIndex, 0

                swApp.SetUserPreferenceStringListValue swDxfMappingFiles, strDxfDefMap


                'Export Flat Pattern

                If SheetMetalBatchExport.chbBendLines.Value = True Then

                  bRet = swModel.ExportFlatPatternView(NewFilePath, 0)


                  bRet = swModel.ExportFlatPatternView(NewFilePath, 1)

                End If

              Next i

        End If



        Compiler gives runtime error 91 object variable or with block variable not set then highlights this line


          boolstatus = swApp.CloseAllDocuments(False)


        Thanks again

        • 91. Re: Batch export to dwg
          Deepak Gupta

          Stephen, attach you DXF mapping file here and I'll try to see why you're getting issues.


          Please use "advanced editor" in case you want to attach any files. Click on reply and then click on "Use advanced editor". Scroll down to see the option to attach file. ".



          • 92. Re: Batch export to dwg
            Stephen Muir

            This is the file that i am trying to use. i have only used it once or twice but it works fine for manually exporting single part flat patterns.


            • 93. Re: Batch export to dwg
              Patrick O'Hern

              You know, I'm not sure if the DXF map even works with ExportFlatPatternView.  I pulled that from my own DXF macro, but I actually create a dummy drawing and insert a view of the flat pattern, then use SaveAs to save the file to DXF.

              • 94. Re: Batch export to dwg
                Stephen Muir

                Well After accidentally leaving the show map dxf during each save option on i realize that the map file is being referenced but there doesnt seem to be a bend line entity in the active document as my map file is preset to map bend lines to a BEND layer but when the dialogue came up the entity type had been changed from bend lines to bounding box and there was no bend line option to return it to.


                Does the exportflatpatternview call Perhaps assign bend lines a different entity type?

                • 95. Re: Batch export to dwg
                  Patrick O'Hern

                  I believe bend lines count as centerlines to the dxf map

                  • 96. Re: Batch export to dwg
                    Stephen Muir

                    Im not sure how i got that to work on friday now everything has stopped working again the original macro works but doesnt bring up the mapping window and my modified macro doesnt do anything , i had snippets from different things i had tried saved in a text file and now nothing works it keeps saying user defined type not defined on a dim statement "dim userpreference as system.integer" but im sure i used the identical statement before without problems.

                    • 97. Re: Batch export to dwg
                      Solidworks Selim

                      Batch slddrw to dwg


                      macro does not work

                      • 98. Re: Batch export to dwg
                        Stephen Muir

                        So,, Export to DWG does use the dxf map Apparently i forgot to save on friday but i finally found my mistake and i am now able to batch export sheet metal parts with mapped entities To DXF. Thanks for all your help Guys.

                        • 99. Re: Batch export to dwg
                          Humberto Galvez

                          Could you share??



                          • 100. Re: Batch export to dwg
                            Humberto Galvez

                            That's a great macro, very useful.But, I wonder if it's possible to add the dxf mapping option to the macro?


                            Thanks for your help.

                            • 101. Re: Batch export to dwg
                              Stephen Muir

                              I'm happy to help and provide the code excerpt that worked for me, however I can take no credit for the rest and I am a sloppy code writer so I wouldn't recommend using my macro. I think along the way to making it work for me I may have broken the option to turn off bend lines as I always want them anyways and the DWG option as well which again I don't use. I will post the snippet tomorrow when I'm back at work

                              • 102. Re: Batch export to dwg
                                Stephen Muir

                                Dim swPart As SldWorks.PartDoc

                                Dim sModelName As String

                                Dim sPathName As String

                                Dim varAlignment As Variant

                                Dim dataAlignment(11) As Double

                                Dim varViews As Variant

                                Dim dataViews(1) As String

                                Dim options As Long



                                    Set swApp = Application.SldWorks

                                    Set swModel = swApp.ActiveDoc


                                    sModelName = swModel.GetPathName

                                    sPathName = swModel.GetPathName

                                    sPathName = Left(sPathName, Len(sPathName) - 6)

                                    sPathName = sPathName + "dxf"


                                    Set swPart = swModel


                                    dataAlignment(0) = 0#

                                    dataAlignment(1) = 0#

                                    dataAlignment(2) = 0#

                                    dataAlignment(3) = 1#

                                    dataAlignment(4) = 0#

                                    dataAlignment(5) = 0#

                                    dataAlignment(6) = 0#

                                    dataAlignment(7) = 1#

                                    dataAlignment(8) = 0#

                                    dataAlignment(9) = 0#

                                    dataAlignment(10) = 0#

                                    dataAlignment(11) = 1#


                                    varAlignment = dataAlignment


                                    dataViews(0) = "*Current"

                                    dataViews(1) = "*Front"


                                    varViews = dataViews



                                  options = 13

                                    swPart.ExportToDWG2 NewFilePath, sModelName, 1, True, varAlignment, False, False, options, Null



                                As i said yesterday this is only the section of code that i changed to get the band lines mapped, i was not careful about updating the variables in this section therefore they dont match the options that the original authors had built into the macro.

                                • 103. Re: Batch export to dwg
                                  Humberto Galvez

                                  In which part do you put this code?? Do you switch this code instead Export flat pattern?



                                  • 104. Re: Batch export to dwg
                                    Stephen Muir

                                    This code should be part of the command That runs when the export to dxf button is clicked.


                                    Yes that code Would Replace the Exportflatpatternview code in the original macro however i dont believe that you can just copy and paste this over the other as the other variables in the macro are different than the code i posted.

                                    As I said i am willing to help, however i can take no responsibility for the accuracy of modified code as i am not a professional code writer, just an SW User.


                                    With API Help And Examples i pieced it togethor until i could make it work but i do not allow others in my company to use my modified macro in case i made a mistake

                                    5 6 7 8 9 10