I guess I should start off by saying I have little to no experience writing code -__- . I have been trying to use different examples from various sources but I continuously get errors and dont understand how to properly debug them (or if I am even using the correct code for what I want to achieve).
I am implementing Radan for our Nesting Software and have been relatively successful with its application for our manufacturing process. The first issue I ran into was how our material templates were set up in Solid Edge. We use all Stainless Steel so our filtering should have been easy, but whoever set up the templates included the gage size and finish in the material type - I.E. 14 Ga SS 2B. After communication with some people at Vero they have generated a DTM plug-in for us that allows Radan to extract file property information from Solid Edge. This has helped us quite a bit and opened alot of doors for us without having to change our template structure.
My issue now is that our template does not include the material grade (301, 304, 316)... I would rather not create 2 additional templates so Radan can filter the grade of Stainless. This would require us to edit thousands of parts in our current library and also make duplicate parts of the same thing just to change the material selection as customers might order an upgraded material for a standard machine.
I need help writing a Macro (honestly, I dont know how to start) that will extract the material for all of the sheetmetal parts in the desired assembly. Next, I envision a form to pop up and ask the user to select the material grade (301, 304, 316). After the grade has been selected I expect the macro to add the information to the extracted material properties and paste them in the file properties under something like "Keywords".
Any and all insight on the matter will be greatly appreciated.
This code gets the material of the sheet-metal part and writes it to a custom propertie named "Keywords". It works for the active document in Solid Edge, so a sheet metal part must be opened to work.
What line of code is it complaining about? The only thing I see off hand that won't work is this line:
Set objNewProperty = objSubProp.Add("Keywords", MyMaterial)
This is because you can only "Add" properties to the "Custom" property set. The correct code should be
Set objNewProperty = objSubProp.Item("Keywords") objNewProperty.Value = MyMaterial
Thanks, I appreciate any insight as I am still just learning. However, I am still receiving the compile error, method or data member cannot be found? The de bugger just highlights the Sub Rad_Import?
The following code is incorrect and should be removed.
SolidEdgeFramework.PropertySets = Nothing SolidEdgeFramework.Properties = Nothing SolidEdgeFramework.Property = Nothing
I didn't catch it at first glance.
I would like to start off by saying thanks for all the support, this is my first macro I used VBA and I have started looking at VB.net (this is the start of something new and exciting for me). Through this forum I have been able to piece together various samples and make this work the way I hoped it would (I am almost 100% satisfied with my code) all while learning more about API. With that said I am having a little trouble with editing sub-occurrences within sub-ocurrences, etc... I have seen various examples pointing to top layers and recursive code working from bottom up but I cant quite grasp it and put it into context. I understand it in theory but I am having a difficult time applying it. If anyone could help point me towards a solution I would be ecstatic. Here is what I have so far (any pointers or constructive criticism would be greatly appreciated as well):
Dim ObjAsm As SolidEdgeAssembly.AssemblyDocument Dim AsmOcc As SolidEdgeAssembly.Occurrence Dim ObjOccu As SolidEdgeAssembly.Occurrences Dim AsmDoc As solidedgeframework.SolidEdgeDocument Dim SubOcc As SolidEdgeAssembly.SubOccurrences Dim ObjSubOcc As SolidEdgeAssembly.SubOccurrence Dim ObjPar As solidedgepart.SheetMetalDocument Dim ObjPropSet As solidedgeframework.PropertySets Dim ObjSubProp As solidedgeframework.Properties Dim ObjMyProp As solidedgeframework.Property Dim MyMaterial As solidedgeframework.Property Dim MATtest As solidedgeframework.Property Dim ObjDocument As solidedgeframework.SolidEdgeDocument Dim ObjApp As solidedgeframework.Application Dim i As Integer Dim j As Integer Set ObjApp = GetObject(, "solidedge.application") Set ObjAsm = ObjApp.ActiveDocument Set ObjOccu = ObjAsm.Occurrences For i = 1 To ObjOccu.count Set AsmOcc = ObjAsm.Occurrences(i) If Right(AsmOcc.OccurrenceFileName, 3) = "psm" Then Set AsmDoc = AsmOcc.OccurrenceDocument Set ObjPar = AsmDoc ElseIf Right(AsmOcc.OccurrenceFileName, 3) = "asm" Then Set SubOcc = AsmOcc.SubOccurrences For j = 1 To SubOcc.count Set ObjSubOcc = SubOcc(j) If Right(ObjSubOcc.ThisAsOccurrence.OccurrenceFileNam
e, 3) = "psm" Then Set ObjPar = ObjSubOcc.ThisAsOccurrence.OccurrenceDocument Set ObjPropSet = ObjPar.Properties Set ObjSubProp = ObjPropSet.Item("MechanicalModeling") Set ObjMyProp = ObjSubProp.Item("Material") Set MATtest = ObjSubProp.Item("Material") Set ObjDocument = ObjPar End If If Left(MATtest.Value, 4) = "12GA" Or Left(MATtest.Value, 4) = "20GA" Or Mid(ObjPar.Name, 4, 3) = "800" Then Set ObjSubProp = ObjPropSet.Item("Custom") Set MyMaterial = ObjSubProp.Add("RAD_IMPORT", MATtest.Value & " 304") Else Set ObjSubProp = ObjPropSet.Item("Custom") Set MyMaterial = ObjSubProp.Add("RAD_IMPORT", MATtest.Value & " 301") End If Next j End If Set ObjPropSet = ObjPar.Properties Set ObjSubProp = ObjPropSet.Item("MechanicalModeling") Set ObjMyProp = ObjSubProp.Item("Material") Set MATtest = ObjSubProp.Item("Material") Set ObjDocument = ObjPar If Left(MATtest.Value, 4) = "12GA" Or Left(MATtest.Value, 4) = "20GA" Or Mid(ObjPar.Name, 4, 3) = "800" Then Set ObjSubProp = ObjPropSet.Item("Custom") Set MyMaterial = ObjSubProp.Add("RAD_IMPORT", MATtest.Value & " 304") Else Set ObjSubProp = ObjPropSet.Item("Custom") Set MyMaterial = ObjSubProp.Add("RAD_IMPORT", MATtest.Value & " 301") End If Next i MsgBox (MyMaterial.Value) Set ObjSubProp = Nothing Set MyMaterial = Nothing Set MATtest = Nothing End Sub