Reply

Duplicate a material with a new color

[ Edited ]

 

Hi

 

I would like to duplicate a facestyle, change some of it's properties. And finally, duplicate a material with a new style.  As you can see in my sample, I'm missing many values.

 

Thanks

-------------------------

VBS Sample:

 

Public oSEApp

Public oSEMatTable

...

Set oSEApp = GetObject(, "Solidedge.application")

Set oSEMatTable = objSE.GetMaterialTable

...

 

Dim oFaceStyle

 

Set oFaceStyle = DuplicateFaceStyle("MetalUnpainted", "MetalBlue")

oFaceStyle.SetAmbient(0,0,1)

 

Call DuplicateMaterial("SteinlessUnpainted", "SteinlessBlue", "MetalBlue")

...

Call oSEMatTable.ApplyMaterial(oPart, "SteinlessBlue")

...

 

Function SEDuplicateFaceStyle(sOldName, sNewName)

  'Return the new FaceStyle object

  Set SEDuplicateFaceStyle = ???

End Function

 

Sub SEDuplicateMaterial(sOldName, sNewName, sStyleName)

 

  Dim MatCount, MatList, i

 

  Call oSEMatTable.GetMaterialList(MatCount, MatList)

  For i = 1 To MatCount

    IF UCase(MatList(i)) = UCase(sOldName)

      'Create a new material from the material #i

 

      Call oSEMatTable.AddMaterial(sNewName, ?, ?, sStyleName, ?, ?)

    End If

  Next

 

End Sub

 

Posted by: Pascal Boivin
Post date: 6/23/2009 8:01:39 AM

2 REPLIES

RE: Duplicate a material with a new color

[ Edited ]

To duplicate a facestyle:

You must have a PAR file open. The face style will be created in that PAR file. Maybe you want to open one of your templates to get advantage of that new facestyle in future designs.

With your file open:

set oPAR=oSEapp.ActiveDocument

'This "copies" a new style from one existing.

set oFaceStyle=oPAR.Facestyles.Add(NewName, OldName)

 

'I couldn't make AddMaterial work. So the easiest way i foresee to create the new material is to export the materials to an XML file, edit it adding the new material and import the XML again.

There are functions for that:

WriteMaterialDataToXML(String)

WriteMatLibFileFromXML(String, String)

 

Posted by: Julian Guillo
Post date: 6/24/2009 3:31:00 AM

RE: Duplicate a material with a new color

[ Edited ]

 

Nice!  Thank you

 

Posted by: Pascal Boivin
Post date: 6/26/2009 2:32:08 AM