I do a lot of assembly of sheet metal. In my BOM I need to use the cutlist ( width, lenght..) information without have 2 lines for each part ( making by the indented option ) .
I see only 2 way. First, use the INdented option and delete each Part Only line. The second way, by copying the cutlist property a want to the part custom property and use the PART ONLY bom.
I prefer the second way to reduse the risk on error.
My question is, there is a way to link the cutlist pproperty to the model custom properrty in a way that is updated when the value change??
I know how to make macro to make what i want, but i have to run my macro each time.
I see a video with MACRO FEATURE can make this, but a don't know how to upgrade my macro to a macro feature.
Did some one have a tutorial??? A macro feature is the same thing of a Custom feature??
SolidworksApi macros
Bob,
You could use a macro feature or you could use an equation-triggered macro if you want code to run on every rebuild (or whenever some other event occurs---as long as a delegate exists for that event in swAppNotify_e., swPartNotify_e, swDrawingNotify_e, etc). I would recommend an ETM. Macro features are difficult to implement and maintain, and I would only recommend them when you need a custom feature to add to your feature tree.
Keith
SolidWorks API Tutorials
This is what Adam wrote about this topic:
http://www.javelin-tech.com/blog/2013/05/link-property-to-note-not-the-other-way-around/
Thank Keith
It work more than i expect. When i quit the Equation Manager, it give me a syntax error, but all work fine.
The exemple in the link do the same thing, so, i don't worry about it.
Hi Keith
It' s wierd. My equation triggered macro work just the first time a making it. Yesterday i re-work on my project and the Macro did't work.
I notice that in the exemple giving in the equation-triggered macro the EVALUATES TO is 1, and in my part is nothing. Also now, when I import the equation #1 my Solidworks crash but not with the equation #3. I just try to import equation #2 without having the macro in the Design Binder and no problem
equation #1 : "Var2"= 1::swApp.RunAttachedMacro "CutList_to_prop.swp" , "mMain" , "main"
equation #2 : "Var4"= 1::swApp.RunAttachedMacro "rename bodies.swp" , "mMain" , "main"
equation #3 : "Var3"= "1::swApp.RunAttachedMacro" "CutList_to_prop.swp" , "mMain" , "main"
I don't understand because i change nothing in on my computer.
Please, Can you help on that ???
this is my code:
Sub main()
Dim swApp As SldWorks.SldWorks
Dim longstatus As Long, longwarnings As Long
Dim thisFeat As SldWorks.Feature
Dim thisSubFeat As SldWorks.Feature
Dim custPropMgr As SldWorks.CustomPropertyManager
Dim retValue As Integer
Dim retDescription As String
Dim retDescription1 As String
Dim retLENGTH As String
Dim retLENGTH1 As String
Dim retWidth As String
Dim retWidth1 As String
Dim retSheet As String
Dim retSheet1 As String
Dim names As Variant
Dim cutListFolder As SldWorks.BodyFolder
Dim boolstatus As Boolean
Dim value As Integer
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set thisFeat = Application.SldWorks.ActiveDoc.FeatureByName("Solid Bodies")
Set cutListFolder = thisFeat.GetSpecificFeature2
Debug.Print cutListFolder.SetAutomaticCutList(True)
If Not cutListFolder Is Nothing And cutListFolder.UpdateCutList Then
Debug.Print "Updated"
Set thisSubFeat = thisFeat.GetFirstSubFeature
Do While Not thisSubFeat Is Nothing
If thisSubFeat.GetTypeName = "CutListFolder" Then Set cutListFolder = thisSubFeat.GetSpecificFeature2
If Not cutListFolder Is Nothing And cutListFolder.GetBodyCount > 0 Then
Set custPropMgr = thisSubFeat.CustomPropertyManager
names = custPropMgr.GetNames
If UBound(Filter(names, "Bends")) > -1 Then
boolstatus = custPropMgr.Get4("Bounding Box Width", True, retWidth, retWidth1)
boolstatus = custPropMgr.Get4("Bounding Box Length", True, retLENGTH, retLENGTH1)
bRet = swModel.DeleteCustomInfo2("", "Long")
pbRet = swModel.AddCustomInfo3("", "Long", swCustomInfoText, retLENGTH1)
bRet = swModel.DeleteCustomInfo2("", "Larg")
pbRet = swModel.AddCustomInfo3("", "Larg", swCustomInfoText, retWidth1)
End If
If UBound(Filter(names, "ANGLE1")) > -1 Then
boolstatus = custPropMgr.Get4("LENGTH", True, retLENGTH, retLENGTH1)
bRet = swModel.DeleteCustomInfo2("", "Long")
pbRet = swModel.AddCustomInfo3("", "Long", swCustomInfoText, retLENGTH1)
bRet = swModel.DeleteCustomInfo2("", "Larg")
End If
End If
Set thisSubFeat = thisSubFeat.GetNextSubFeature
Loop
End If
End Sub
This discussion should give you a very good start:
This is using a macro, but the macro will run on each rebuild.
Devon, in this thread and the 2 other threads you mentioned me (which I appreciate -- thank you), you actually linked to your inbox, not to the thread itself, so the links don't work for anyone except you. FYI.
Change them. Thanks you.