ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
SJShaun Jalbert25/06/2015

I have a script that goes through a bunch of routines, but the one of interest looks at any extruded plates and recognizes if the material assigned has "GRTG" in the name implying grating and if it does, then it pulls the material name (string) apart to populate the Cut List Properties. This function works really well.

So we identified that we need another function to identify if the material has "EXP METAL" in the name implying expanded metal. If it does, then we want the Cut List Properties populated a certain way.

The material is as follows:

5.00#/SQ FT (CS) EXP METAL

where:

StockSize_Short = 5.00#/SQ FT

Grade = CS

Type = EXP METAL

From this string, the following Cut List Properties would populate:

StockSize = StockSize_Short x SW-3D-Bounding Box Width x SW-3D-Bounding Box Length x Type

Description = Expanded Metal

For reference, my plates, I've been using this string to populate the Stock Size and I want to use this method to populate both the SW-3D-Bounding Box Width & Length (noted above) the same way.

bRet = f.CustomPropertyManager.Add(propname4, proptype, Chr$(34) + "PL" + "SW-3D-Bounding Box Thickness@@@" + f.Name + "@" + doc.GetTitle + ".SLDPRT" + Chr(34) + "x" + Chr(34) + "SW-3D-Bounding Box Width@@@" + f.Name + "@" + doc.GetTitle + ".SLDPRT" + Chr(34))

Here's the Grating Code for Reference:

             Dim sMaterial As String
             sMaterial = GetFeatureCustomProp("Material", f)
             If Not sMaterial = "" Then
             Dim iP As Integer
             iP = InStr(1, sMaterial, "GRTG")
                'If the material is grating then let's change the values
                If iP > 0 Then
                ChangeCustomPropForGrating sMaterial, f
                End If 'End of material being grating if
             End If 'End of material being blank if

Sub ChangeCustomPropForGrating(ByVal TheMaterial As String, ByVal TheFeature As SldWorks.Feature)

Dim bRet                As Boolean

Dim iGrtg               As Integer

Dim iSpace              As Integer

Dim sGrade              As String

Dim sStockSize          As String

Dim sStockSize_Short    As String

Dim sType               As String

sType = "GRTG"

iGrtg = InStrRev(TheMaterial, sType)

If iGrtg > 0 Then

   iSpace = InStr(1, TheMaterial, " ")

   sGrade = Left(TheMaterial, iSpace - 1)

   sStockSize = sGrade + " " + Trim(Mid(TheMaterial, iSpace, iGrtg - iSpace))

   sStockSize_Short = sGrade + " " + Trim(Mid(TheMaterial, iSpace, iGrtg - iSpace))

   bRet = TheFeature.CustomPropertyManager.Set2(propname5, sGrade)

   bRet = TheFeature.CustomPropertyManager.Set2(propname4, sStockSize)

   bRet = TheFeature.CustomPropertyManager.Set2(propname11, sStockSize_Short)

   bRet = TheFeature.CustomPropertyManager.Set2(propname3, sType)

   bRet = TheFeature.CustomPropertyManager.Set2(propname2, "BAR GRATING")

End If

End Sub

How can I manipulate this to work as intended. I tried copying and pasting this and modifying, but I can't figure it out.

(Full macro is attached)

Thanks,

Shaun