Für den Fall, das es jemanden außer mir interessiert habe ich hier die Antwort vom SWX
-Support angehängt (Vielen Dank an das TeamWorks-Team).
Piet
To be able to get and set the material on a Part that is used by CosmosExpress, please have a look at:
PartDoc.GetMaterialPropertyName2
PartDoc::SetMaterialPropertyName2
SldWorks::GetMaterialDatabases
SldWorks::GetMaterialSchemaPathName
The XML containing the material definitions for a particular material database can be obtained using:
ModelDocExtension::GetStream
ModelDocExtension::ReleaseStream
See the examples coming with these last 2 methods. You can use the DOM object model to process the XML.
You can add to the list of physical properties of a material by changing the XML scheme. This is an unsupported kind of customization. Please refer to the outline at the end of this email of how to do this.
__________________________________________________________________________________________________
Suppose you want to add a physical property "MYPROP". You will need to add this "MYPROP" type to:
C:\Program Files\SolidWorks2005\data\xmlschema\sldmaterials.xsd
Look for this tag:
<xsd:element name="physicalproperties" minOccurs="0">
and add something like this:
<xsd:element name="MYPROP" type="sldmaterials:curveControlled" minOccurs="0"/>
Now for the materials in the material database "solidworks materials.sldmat", add a line like this inside the <physical properties> node:
<MYPROP displayname="My Property" value="11.11E+8"/>
like so:
<material name="AISI 304" matid="1">
<shaders>
<pwshader name="stainless steel"/> <!-- OK -->
<cgshader name="SteelAISI304"/>
<swtexture path="images\textures\metal\cast\cast_fine.jpg"/>
</shaders>
<swatchcolor RGB="9DA4AC">
<sldcolorswatch ptical Ambient='0.520000' Transparency='0.000000' Diffuse='0.800000' Specularity='1.000000' Shininess='0.400000' Emission='0.000000'/>
</swatchcolor>
<xhatch name="ANSI32 (Steel)" angle="0.0" scale="1.0"/>
<physicalproperties>
<EX displayname="Elastic Modulus" value="0.19E+12"/>
<NUXY displayname="Poissons Ratio" value="0.29"/>
<GXY displayname="Shear Modulus" value="0.75E+11"/>
<ALPX displayname="Thermal Expansion Coefficient" value="0.18E-4"/>
<DENS displayname="Density" value="0.80E+04"/>
<KX displayname="Thermal Conductivity" value="16."/>
<C displayname="Specific Heat" value="0.50E+03"/>
<SIGXT displayname="Tensile Strength" value="5.17017E+8"/>
<SIGYLD displayname="Yield Strength" value="2.06807E+8"/>
<MYPROP displayname="My Property" value="11.11E+8"/>
</physicalproperties>
</material>
Please note there is a different "solidworks materials.sldmat" file for each language supported by SolidWorks.
__________________________________________________________________________________________________
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swPart As SldWorks.PartDoc
Dim sMatName As String
Dim sMatDB As String
Dim bRet As Boolean
Dim vMatDBarr As Variant
Dim vMatDB As Variant
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swPart = swModel
Debug.Print "MaterialSchemaPathName = " & swApp.GetMaterialSchemaPathName
vMatDBarr = swApp.GetMaterialDatabases
For Each vMatDB In vMatDBarr
Debug.Print " " & vMatDB
Next
sMatName = swPart.GetMaterialPropertyName2("Default", sMatDB)
Debug.Print "File = " & swModel.GetPathName
Debug.Print " Material = " & sMatName & " (" & sMatDB & ")"
End Sub
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP