4 Replies Latest reply on Jul 20, 2016 9:39 PM by Viktor Bovzdarenko

    Generate barcode from drawing template variables?

    Jovan Tisma



      I’m creating a barcode system that tracks and identifies all my solidworks drawings.  Currently, I manually enter all necessary information into a barcode generating software and copy and paste the barcode on my solidworks drawings.  I want to make this an automated process where solidworks automatically generates the barcode using the drawing template variables.  I have the software to generate the barcodes I just need to know how to pass drawing template variables to my software.  How would I go about doing this so that everything can be done only using solidworks?

        • Re: Generate barcode from drawing template variables?
          John Alexander

          What information are you gathering to enter into the barcode generator? How is it stored in your CAD data? I'll hazard a guess that they are inside Custom properties?


          You can use the CustomPropertyManager to read and write custom properties for parts, drawings, assemblies.

          2012 SOLIDWORKS API Help - CustomPropertyManager Property (IModelDocExtension)


          In your manual process, how are you inserting the bar codes? Are they images or some sort of DXF line file?


          If it is an image, you could use the barcode software to save the image and then import that image into your drawing - I would suggest giving the barcode images unique file names.


          You can create SketchPicture objects by specifying a path to an image file (tif, bmp, jpeg, etc) and an insertion point on the sheet sketch.

          2012 SOLIDWORKS API Help - ISketchPicture Interface Members


          If it exports something like a DXF, I'm not personally familiar with how those are imported into a drawing but I'm sure there is a way of doing that.


          The meat of your question lies in between these two tasks. You want to run your Barcode generator programmatically.


          This is a matter of investigating what API (if any) your barcode software exposes. In the ideal case, it would be a matter of adding their libraries in the macro's reference list, and calling whatever functions they provide with the information that you gather from your SolidWorks model. This can all be done in one SolidWorks macro. However, if they don't provide any of that, you may have to get creative. At the very least, you can play around with the command line to figure what arguments can be passed to the executable.

          • Re: Generate barcode from drawing template variables?
            Josh Brady

            Assuming your bar codes are industry-standard Code 39 type, there are TrueType fonts available for free download that create bar codes directly from plain text.  Just add a note on your template, link it to custom property, and change the font type to that font.


            One caveat: If you send your drawing files to someone who doesn't have that font installed, the note will revert to the default font for the drawing.

            • Re: Generate barcode from drawing template variables?
              Viktor Bovzdarenko

              Hi Jovan,

              try #TASK . There is a task in the library which generates and adds QR codes in batch (for thousands of drawings).

              As an input can be used a custom property, conisio url from ePDM, drawing path, name....



              Hope this helps