14 Replies Latest reply on Dec 21, 2015 8:35 AM by Amen Allah Jlili

    Update part custom properties from a drawing without opening part

    Tony Thompson

      Hi

       

      I am looking to create a Macro that will update a custom property of a part from within a drawing without having to open the part.

      I have several custom properties assigned to a part or an assembly and one of them is named Shop Order and this is the job number assigned to the part to be able to track it's cost and progress through the shop. This is just an incremental 5 digit number assigned to each job and the Shop Order custom property is used to populate the title block of the drawing and one of the Engineers is complaining about having to open the part and drawing to change the Shop Order for repeat parts. For example a new part may have the Shop Order 45987 the first time it is made then the customer may order a replacement or backup so the SolidWorks drawing is opened and the Shop Order might be 49852 now and the only way to change the custom property of the part is to also open it and change the Shop Order number so it will update the title block of the drawing.

       

      What I would like to do is create a Macro that would update the Shop Order custom property of the part or assembly in the drawing views without having to open the part. I would like to create a toolbar button or a keyboard shortcut and when the Macro is ran a dialog box would open with a text box to enter the new Shop Order number into and an OK or Update button in the dialog box that would change the Shop order of the part. I know you can do this with Task Scheduler but it takes longer and is too cumbersome just to change the Shop Order of a single part but if I re-release an entire punch press die that has dozens of drawings then I would use Task Scheduler for this the Macro I want to create would be for single parts that are reordered. I am no expert at VB but have dabbled in it mostly in Excel.

       

      We are using SolidWorks 2015 (I have Premium but the rest of the shop has Professional) but look to update to 2016 after the first of the year so I would need the Macro to be able to run in SolidWorks 2016 also.

       

      Thanks

      Tony

          • Re: Update part custom properties from a drawing without opening part
            Tony Thompson

            No. We are just using a Windows 2011 Small Business Server but no EPDM.

             

            Thanks

              • Re: Update part custom properties from a drawing without opening part
                Amen Allah Jlili

                Insert a bom table with a custom property as the column, you'd able to change the part custom property by editing the cell inside the bom without having to open the part.

                  • Re: Update part custom properties from a drawing without opening part
                    Tony Thompson

                    Thanks

                     

                    That is how I have it setup now but this doesn't work for assembly drawings because the BOM is a list of all of the parts but the assembly file itself also has the Shop Order custom property. I have form and some of the Macro already created but I can't figure out how to access the part or assembly that is in a drawing view. I know this can be done because that is what is happening when you edit the Shop Order cell in the BOM. I even tried recording a Macro while I edited the BOM and this created a MyTable.txt array and it has the SO that I entered where it changed it so I simply changed this number in the Macro and ran it but it gives an error and won't even run if you don't make any changes to it so I am lost at this point. Below is the code I get when I record editing the BOM.

                     

                     

                    Dim swApp As Object

                    Dim Part As Object
                    Dim boolstatus As Boolean
                    Dim longstatus As Long, longwarnings As Long

                     

                    Sub main()

                    Set swApp = _
                    Application.SldWorks

                    Set Part = swApp.ActiveDoc
                    boolstatus = Part.Extension.SelectByID2("DetailItem74@Sheet1", "ANNOTATIONTABLES", 0.193733195528771, 0.251054468874127, 0, False, 0, Nothing, 0)
                    Part.ClearSelection2 True
                    Dim myTable As Object
                    Set myTable = Part.SelectionManager.GetSelectedObject5(1)
                    myTable.Text(1, 0) = "12345"
                    boolstatus = Part.Extension.SelectByID2("Sheet1", "SHEET", 0.147002767687836, 0.245434987045154, 0, False, 0, Nothing, 0)
                    End Sub

                     

                     

                    Thanks

                      • Re: Update part custom properties from a drawing without opening part
                        Amen Allah Jlili

                        Just a curious question (because this is my field of expertise as a quality assurance engineer): How will you keep track of parts number (for example different versions) versus shop orders?

                         

                        According to your logic the CAD part models will always have the latest shop order number. Shouldn't the shop order be a custom property of the drawing rather than the part? That's how I designed my employer's floor shop MRP. If you manufacture parts which are standardized or have some degree of standardization (not subject to many changes which I'm only assuming), then the SO custom property is better suited for the drawing document which will eventually change from an order to another. What should be included in the part is the part version, perhaps ? Unless every SO has exclusive new parts, It would be understandable to put to the SO property in every part but traceability problems will emerge once a part is used in many SO and if you don't keep a BOM in every document, you'll be lost then.

                          • Re: Update part custom properties from a drawing without opening part
                            Tony Thompson

                            Amen

                             

                            We have a system that the part numbers are linked to the Shop Order that is used to track the progress and cost of the parts. As far as versions we always make the latest version and don't typically have to make different versions of a part.

                             

                            As for the Shop Order being in the part instead of the drawing we had that discussion and the reason we chose to have the Shop Order in the part and assembly instead was ease of creating the drawings because we have the title blocks populated with links to all of the custom properties in the part or assembly that we want in the drawings and have Custom Property Tab templates for the part and assembly files to create these custom properties. The only custom property we have in the drawings is Revision so that it is linked to the Revision Table. As for the traceability of the part and Shop Order numbers as I said we have a system that tracks this so we can go back and find every SO# that a specific part number was ran against and we can compare the timing and cost for each time we ran the part to verify that our processes are consistent and that are cost are within a certain range for each build. We build specialized tooling, Special machines and Punch press dies for the Auto industry and have a fair amount of repeat orders and we almost always build to the latest revision. So I understand what you are saying but the goal was to not have to create any custom properties in the drawings and have all of the information we require in the part and assembly files and that is working out well for us so far and the only complaint is by one of the engineers because he doesn't want to open the part for repeat orders just the drawing. For now we have the SO# in the BOM in part files so we can just click in the cell and change the SO# for both the part and drawing but this doesn't work for assembly files but the assembly drawings are not normally re-released unless the customer buys a complete tooling package for backup and for now we are using the SolidWorks Task Scheduler to change the SO# for the entire group of parts and assemblies. We have a specific location in the title block we have the SO# so that when the drawings are folded can be read without having to unfold the drawing and we also have a stamp note on the drawing in a specific location that is also linked to the SO# .

                             

                            I thought this would be a fairly simple thing to do with a Macro until I tried to access the part file that was in a drawing view but I can't seem to find a way to do this but since you can do this in the BOM I am convinced there is a way to do this in a Macro I just need some help getting access to the part or assembly in one of the drawing views.

                             

                            Thanks

                              • Re: Update part custom properties from a drawing without opening part
                                Amen Allah Jlili

                                Hello Tony!

                                 

                                Thanks for taking the time to explain your process flow thoroughly! Every company is different another but the greatest challenge of organisational change is maintenance!

                                 

                                Back to the topic now:

                                 

                                The root of the problem (As I understand it):
                                As of today, the option to include the assembly as the 0th item in a BOM does not exist in Solidworks. I think this is a feature they should include in future releases as many people have requested. According to my research, this leaves you with two options:

                                 

                                Option 1 (Which I recommend):
                                This first option is a workaround that does not require a macro. You simply create an empty assembly (Master assembly) inside which you add the assembly that you want to appear in the BOM. When adding the assembly, make sure that the assembly's origin coincidence with the Master assembly's. Save the Master assembly and create a new drawing from it. Now, whenever you insert the BOM, the assembly will appear in the BOM as the 1st item and you can simply change the custom property of the assembly as you would do with any part.

                                 

                                Pros:

                                -No need for macros.
                                -Perfect if your design's component hierarchy tree does not include many assembly levels. My bet is this will only be done to the largest assembly.

                                -Flexibility with BOM templates:

                                -Renaming custom property fom the BOM

                                -Reordering columns etc...
                                Cons:
                                - New drafting procedure (If you have many assemblies to be drawn with BOMs, you would have to repeat this)

                                 

                                Hope, the following screenshot illustrates my point.
                                preview.png

                                 

                                Option 2:

                                This option includes the use of a macro. The macro will take the SO number from the drafter and basically attempt to add a 0th item to the BOM and fill that 0th row with the necessary data such as:

                                - Part Name
                                - Custom property

                                - Quantity (obviously its one)
                                ...


                                Pros:
                                - No need to add the extra layer of empty assembly
                                Cons:
                                - Each time the SO increments, the macro will increment the SO in the BOM for the assembly row, yet, the assembly's custom will not increment (This should be added a feature to the macro but will make the macro clunky).
                                - No actual link between the assembly's custom property and BOM. I personally call them cosmetic links.
                                - BOM becomes rigid as the macro would be coded around a specific BOM template. You will be tied to one BOM template.

                                - Complex macro.

                                 

                                You weigh the two options and decide. I'd be more happy to help with the macro if you choose the second option ( I highly advice against).

                                  • Re: Update part custom properties from a drawing without opening part
                                    Tony Thompson

                                    Amen

                                     

                                    I would prefer to not use the BOM at all for the Shop Order. My goal is to be able to update the link we have in the Title Block which has nothing at all to do with the BOM and to also update the stamp note which are Annotations linked to he part or assembly custom properties.

                                     

                                    I am attaching an image of one of our drawings that show the Shop Order (51143)  links in Magenta so you can see how we have it setup. I removed our company name and address from the title block but this is how we have the borders setup.

                                    Currently when we insert a drawing view the entire title block and stamp note are filled in from the part custom properties and this makes it really nice when creating drawings not to have to bother with entering more custom properties in the drawing as well we prefer to do all of this in the part and assembly files. We currently only have 12 custom properties assigned to the part files. However we are discussing adding more that would be specific to the type of tooling it is for, we are working on this because we are trying to talk the owner into purchasing the EPDM system so we want to start preparing our files to go into the EPDM but we are not sure if or when this might happen.

                                    As far as putting our main assemblies into an assembly I understand what you are doing but I would prefer to just update the part file SO# in the BOM like we are doing now and just open the assembly file along with the drawing file and just update it in the assembly that way. Also the drawing file in the image below has our original BOM it does not have the new BOM with the SO# column added, I wanted to show the drawing the way we would prefer them to look.

                                     

                                    I appreciate you taking the time to try and understand my issue and giving advice.

                                     

                                    Drawing Example.JPG

                                     

                                     

                                    Thanks

                                    Tony

                                    • Re: Update part custom properties from a drawing without opening part
                                      Tony Thompson

                                      Amen

                                       

                                      Also just to make sure you understand my goal for the Macro. I do not want the Macro to update through the BOM we would prefer to not have the SO# in the BOM at all we are just doing this now for a workaround until I can see if I can create a Macro to update the Annotations we have linked to the custom properties but we do not want to do this through the BOM with the Macro which is how I understand your post implies.

                                       

                                      The Macro I recorded I did change the SO# in the BOM just to see what it gave me but this isn't how I want it to work, sorry if this caused confusion.

                                      I was hoping I could see how SolidWorks was accessing the Shop Order custom property and maybe give me a clue how I could access it but it hasn't helped much. The fact that I am not that familiar with VBA in SolidWorks makes it even more frustrating. I have done a fair amount of VBA in Access databases and a little in Excel but I am new to using it in SolidWorks so I am pretty green.

                                       

                                      Thanks

                        • Re: Update part custom properties from a drawing without opening part
                          Tony Thompson

                          I found and easy way to do this.

                          Instead of trying to write a Macro I simply created an editable field in the title block.

                          The way to do this is go to Edit Sheet Format then right click again and select Edit Title Block and resize the box to fit your title box size.

                          The custom properties that you have will show up here as well so I just selected the Shop Order custom property and it will show up in the list in the browser then I selected the green check mark.

                          Now when we have a repeat order and we open the drawing to print out simply double click in the area you defined as title block, the Shop Order field becomes editable and after changing and clicking the green checkmark anything linked to this custom property is also changed including the part or assembly file that is in a drawing view.

                           

                          That works just how we wanted it to work and I didn't have to create any code.

                           

                          Hope this will help someone as well.

                           

                          Thanks

                          Tony