Page 1 of 1

How do you add the correct material

Posted: Fri Oct 22, 2021 12:56 pm
by berg_lauritz
So....
We upgraded yesterday to SolidWorks 2021 and now we will finally be able to link the materials to a gauge table & with this to the thickness (FINALLY!).
Also we are finally able to search for materials in the database - or so we thought:

SolidWorks only allows to search for the TITLE of the material, but not for the description. Which does not help us a lot, because we do not want to name our materials "[material#]-[description]". I cannot believe honestly, that they only allow to search for the title within an .XML file.

LIKE... COME ON! grumph grumph grumph o[ <()>

The goal is to have the correct Material in there, that is used on the floor (a.k.a. the material #) or a material group that can easily be identified (i.e LEATHER (of no specific color)). This is so that we only have to enter this material once and not show the description with it all the time. Plus it would show on the BOM correctly for everybody.

How do you deal with this? Do you search outside of SolidWorks for the material number & assign it then through your own?
Is there a tool, that will let you search properly for the material?
How do you deal with this problem?
Do you just make folders with the description in it? i.e. alum. -> angle -> 9 -> 6 -> .25 -> [material#]
This way you can search for it at least....

Re: How do you add the correct material

Posted: Fri Oct 22, 2021 5:06 pm
by jcapriotti
We put what we need in the Name. I'm guessing the search is not looking at the XML, just the tree structure at run-time which is why its not seeing the other properties such as description. FWIW, Inventor did find it so its searching for more than just the name although not every property. Solid Edge had no search option.

Re: How do you add the correct material

Posted: Mon Oct 25, 2021 9:05 am
by berg_lauritz
jcapriotti wrote: Fri Oct 22, 2021 5:06 pm We put what we need in the Name. I'm guessing the search is not looking at the XML, just the tree structure at run-time which is why its not seeing the other properties such as description. FWIW, Inventor did find it so its searching for more than just the name although not every property. Solid Edge had no search option.
So if you call out the material it would say:

Code: Select all

123-456789 Aluminum 1/8" Tread Plate
?

It's just that we already have 'correct' Material number that we would like to use, because the shop floor uses it. It's actually more work for them to look it up all the time.

Re: How do you add the correct material

Posted: Mon Oct 25, 2021 12:02 pm
by jcapriotti
berg_lauritz wrote: Mon Oct 25, 2021 9:05 am So if you call out the material it would say:

Code: Select all

123-456789 Aluminum 1/8" Tread Plate
?

It's just that we already have 'correct' Material number that we would like to use, because the shop floor uses it. It's actually more work for them to look it up all the time.
Mostly we handle the material BOM manually but are moving toward automating it more.

Our shop doesn't see the Solidworks material name. The material in SolidWorks is based on an engineering material specification document that could cover a range of material form factors. This number and it's description is added as a custom property in the SWX material database. We pull these values with the API to apply it to the regular custom properties.
image.png
The factory might have have several material part numbers for this material that is added by them in the Mfg BOM. For example, for the above "HR Sheet grade 50" they have different gauges and even different stock sheet sizes (36x48, 48x72, etc.). This is done outside of SolidWorks in the MBOM.

Re: How do you add the correct material

Posted: Mon Oct 25, 2021 12:15 pm
by Jim Steinmeyer
We give all of our parts, and materials a 6 digit number. For assigning materials for plate and sheetmetal we create them as sheet metal and then have a gage table for the different materials as well as gage or plate. We then have a macro that will assign the material number and description based on the selected table. Of course this only works for plate and sheet so there are lots of additional materials that require the user lookup a chart and enter the information. For many of those materials we have a small model saved in the design library and do a save as to have the correct shape and material information in the properties. We then change to the correct length.

Re: How do you add the correct material

Posted: Mon Oct 25, 2021 2:26 pm
by JSculley
berg_lauritz wrote: Fri Oct 22, 2021 12:56 pm So....
We upgraded yesterday to SolidWorks 2021 and now we will finally be able to link the materials to a gauge table & with this to the thickness (FINALLY!).
Also we are finally able to search for materials in the database - or so we thought:

SolidWorks only allows to search for the TITLE of the material, but not for the description. Which does not help us a lot, because we do not want to name our materials "[material#]-[description]". I cannot believe honestly, that they only allow to search for the title within an .XML file.

LIKE... COME ON! grumph grumph grumph o[ <()>

The goal is to have the correct Material in there, that is used on the floor (a.k.a. the material #) or a material group that can easily be identified (i.e LEATHER (of no specific color)). This is so that we only have to enter this material once and not show the description with it all the time. Plus it would show on the BOM correctly for everybody.

How do you deal with this? Do you search outside of SolidWorks for the material number & assign it then through your own?
Is there a tool, that will let you search properly for the material?
How do you deal with this problem?
Do you just make folders with the description in it? i.e. alum. -> angle -> 9 -> 6 -> .25 -> [material#]
This way you can search for it at least....
I whipped up an add-in that will let you search for text in the material name or description. The basic building blocks are in place but I 'm curious on how you would like it to work. Would you prefer a tree structure that narrows itself down as you type your search terms like the current name search does? The problem with that is that if the tree lists just material names and a description matches, it might not be obvious that it's a correct match. Another option is to simply have a search form that then lists the results in a tabular form showing name, description, etc and then you could select from the list to apply the material.

Re: How do you add the correct material

Posted: Tue Oct 26, 2021 4:59 pm
by berg_lauritz
JSculley wrote: Mon Oct 25, 2021 2:26 pm I whipped up an add-in that will let you search for text in the material name or description. The basic building blocks are in place but I 'm curious on how you would like it to work. Would you prefer a tree structure that narrows itself down as you type your search terms like the current name search does? The problem with that is that if the tree lists just material names and a description matches, it might not be obvious that it's a correct match. Another option is to simply have a search form that then lists the results in a tabular form showing name, description, etc and then you could select from the list to apply the material.
If we could search for a description - that would solve almost all of our problems! Is it within Solidworks?

@jcapriotti I love your idea (exactly what we would need) but I don't like that it requires an extra step. But is seems that there is no good solution currently.
We will talk with BOM about that & maybe we can come up with a good solution.

Re: How do you add the correct material

Posted: Tue Oct 26, 2021 5:24 pm
by JSculley
berg_lauritz wrote: Tue Oct 26, 2021 4:59 pm If we could search for a description - that would solve almost all of our problems! Is it within Solidworks?
Yes. As a SOLIDWORKS add-in it can be a menu item, toolbar button, etc. I played around with having it pop up when 'Edit Material' is selected, but the results weren't satisfactory (two dialogs showing, one dropping into the background). I haven't given up on that approach entirely but I suspect it isn't doable.

Re: How do you add the correct material

Posted: Tue Oct 26, 2021 7:31 pm
by JSculley
JSculley wrote: Tue Oct 26, 2021 5:24 pm I haven't given up on that approach entirely but I suspect it isn't doable.
Actually it is quite doable. I just needed to read the API docs more carefully. Edit Material now brings up this dialog:
image.png
And search results look like this:
image.png
So...progress.

Re: How do you add the correct material

Posted: Wed Oct 27, 2021 10:10 am
by berg_lauritz
JSculley wrote: Tue Oct 26, 2021 7:31 pm Actually it is quite doable. I just needed to read the API docs more carefully. Edit Material now brings up this dialog:

image.png

And search results look like this:

image.png

So...progress.
Is this on GIT? Which language are you writing it in? C#?
Man, I wish I could help you with this. It looks VERY promising!

Re: How do you add the correct material

Posted: Wed Oct 27, 2021 10:26 am
by JSculley
berg_lauritz wrote: Wed Oct 27, 2021 10:10 am Is this on GIT? Which language are you writing it in? C#?
Man, I wish I could help you with this. It looks VERY promising!
It is C#. I've got the dialog all working correctly. Next is to pass the info back to SOLIDWORKS to apply the material. I have to do a little more work to differentiate between applying to part/bodies and to handle applying to current config/all configs/selected configs. I'll probably add another button to the form that works exactly like the one in the SW dialog:
image.png
Also, storing some of the state between subsequent calls so that it remembers dialog size, selected libraries, etc...

Re: How do you add the correct material

Posted: Thu Dec 02, 2021 1:32 pm
by bnemec
JSculley wrote: Wed Oct 27, 2021 10:26 am It is C#. I've got the dialog all working correctly. Next is to pass the info back to SOLIDWORKS to apply the material. I have to do a little more work to differentiate between applying to part/bodies and to handle applying to current config/all configs/selected configs. I'll probably add another button to the form that works exactly like the one in the SW dialog:

image.png

Also, storing some of the state between subsequent calls so that it remembers dialog size, selected libraries, etc...
I've been getting pressure to do something with our materials "DB". As the list grows and is not sorted people are not finding the correct material or asking for existing material to be added. If it would be possible to work together I'll do what I can.

Re: How do you add the correct material

Posted: Thu Dec 02, 2021 7:09 pm
by JSculley
bnemec wrote: Thu Dec 02, 2021 1:32 pm I've been getting pressure to do something with our materials "DB". As the list grows and is not sorted people are not finding the correct material or asking for existing material to be added. If it would be possible to work together I'll do what I can.
I haven't had time to work on this due to a large looming project deadline, but I do plan on getting back to it, hopefully before the end of the year or early in the new year.

Re: How do you add the correct material

Posted: Tue Jul 05, 2022 4:16 pm
by JSculley
I've finally gotten around to putting together an installer and pushing this to GitHub. The 2022 version is available on the develop branch. I will create an official 0.1 tag and preliminary release tomorrow. If you need a version for a different SW version, submit an Issue

Re: How do you add the correct material

Posted: Fri Jul 08, 2022 10:12 am
by JSculley
Prelease v0.2 which includes the Windows Installer for the add-in is now available here

Re: How do you add the correct material

Posted: Fri Jul 08, 2022 10:34 am
by AlexLachance
I don't know if it's possible, but perhaps you should rename your topic title to reflect your add-in's capacities rather then have it be the question that caused you to create this. You could also add to your original post the link to the Prerelease. so that it is "easier" to find, if this ever picks up a lot of attention.

Re: How do you add the correct material

Posted: Fri Jul 08, 2022 1:17 pm
by JSculley
AlexLachance wrote: Fri Jul 08, 2022 10:34 am I don't know if it's possible, but perhaps you should rename your topic title to reflect your add-in's capacities rather then have it be the question that caused you to create this. You could also add to your original post the link to the Prerelease. so that it is "easier" to find, if this ever picks up a lot of attention.
I've added a separate ' announcement' post in the API topic.

Re: How do you add the correct material

Posted: Fri Jul 08, 2022 4:47 pm
by AlexB
bnemec wrote: Thu Dec 02, 2021 1:32 pm I've been getting pressure to do something with our materials "DB". As the list grows and is not sorted people are not finding the correct material or asking for existing material to be added. If it would be possible to work together I'll do what I can.
I know this is an old post, but I put something together a while back that sorts the existing material DB and them puts a sorted version of the file on your desktop (if you want to compare to make sure stuff isn't missing)

Not sure if you have visual studio installed but this works as a simple console app. I've also attached the console application zipped .exe file if you want that.

Code: Select all

using System;
using System.IO;
using System.Linq;
using System.Xml.Linq;

namespace Material_Database_Sorter
{
    internal class Program
    {
        static void Main()
        {
            Console.WriteLine("Please type the URL or your Material Database:");
            string myURL = Console.ReadLine().Trim();
            if (File.Exists(myURL))
            {
                SortXmlNodes(myURL);
            }
            else
            {
                Console.WriteLine("File does not exist");
            }
        }
        static void SortXmlNodes(string docUrl)
        {
            var xDoc = XDocument.Load(docUrl);
            var parent = xDoc.Elements().FirstOrDefault();
            var comparer = StringComparer.Create(System.Globalization.CultureInfo.CurrentCulture, true);
            var sortedNodes = parent.Elements().OrderBy(node => node.Name.LocalName, comparer);

            parent.ReplaceNodes(sortedNodes);

            foreach (var node in sortedNodes)
            {
                if (node.Name.LocalName == "classification")
                {
                    var sortedChildren = node.Elements().OrderBy(element => element.Attribute("name").Value, comparer);
                    node.ReplaceNodes(sortedChildren);
                }
            }

            string newFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Sorted_" + Path.GetFileName(docUrl));
            xDoc.Save(newFileName);
        }
    }
}

Re: How do you add the correct material

Posted: Tue Aug 02, 2022 1:45 pm
by berg_lauritz
Thank you @JSculley for the amazing add in that I'll be using from now on!

Here the link to the topic!