I need to grab a sheet property (\\\$PRPSHEET:{Material}) and show it in a form, how?
Would it be possible to edit this in the from and update the drawing?
TIA
Pete
SolidworksApi macros
I need to grab a sheet property (\\\$PRPSHEET:{Material}) and show it in a form, how?
Would it be possible to edit this in the from and update the drawing?
TIA
Pete
SolidworksApi macros
What type of form? Is it SW based? If it is not, I don't believe you can due to the property is an internal equation. Hope this helps.
You can insert that in a note or a table. If you have it in a table you can export it to a spreadsheet.
Yes, it's possible through API. Happy programming!
Any chance of an example of how to do this? I am a press ganged programmer, so am not well up with the intricacies of coding!
Hi Peter,
Tried to fix something. Find attached a macro that gets the material assigned to a part and sets a new material if wanted. There is one problem with this approach: I don't know how to list all materials from the material database so you have to know a material name if you want to use it. From API-help:
----
To find out the names of the materials in the SolidWorks materials database:
Open the database as an XML stream and work with the XML API to get the data.
- or -
Click the Edit Material button on the Standard toolbar and examine the names of the materials listed beneath SolidWorks Materials.
-------
Also did not built any solution for different configurations, but that should not be too hard.
If you want to get / set values for custom properties, that should also not be too hard.
Hi Peter, you would have to point to the appropriate ModelDoc2 (this is a little intricate since you are using the SHEET type of property, which read properties from whichever modelview is indicated in the sheet properties), and then you would want to change the material of that ModelDoc2, that should then automatically propagate back to your custom property, which in turn will link back to your property in the drawing. You would never actually be modifying the annotation, but instead the material for the part which that annotation is linking to.
Being all that said, this doesn't seem like a very practical approach (I know I would stay away from it), but it all depends on what your intended application really is and what exactly you are trying to do. So, can you explain to us in a little more detail what you are trying to achieve so we can help you accordingly?
Hope this helps,
Filipe
Could not resist and added a drop down list for materials to select from.
You must set proper address for material database first and this should run after that
(now it has been set as "C:\Program Files\SolidWorks Corp\SolidWorks\lang\english\sldmaterials\solidworks materials.sldmat")
All materials come unsorted so you should maybe group items somehow if you want to use this kind of solution.