I want to make a macro to launch the axemble smartproperties and validate it in order to be able to update some properties driven only by the smartproperties.
The problem is that I don't know the vba and that the macro recorder doesn't seem to work for this macro which seems to be rather simple.
The goal is to then incorporate this macro to make it a feature macro that would update the properties of the part with each change.
No matter how much I look on google and other I don't have to type the right search items to launch a macro from a SW macro...
Each time the file is modified, because we retrieve the designation of the room to make our orders automatically with our ERP and the bandwidth as well as the length in the designation must be updated and this is only done when launching smartproperties.
EDIT: Hence the desire to incorporate this macro into a feature macro
The problem is that only 1 coin out of 500 has this macro so I can't run it via Custom Toolbar / local help
I see a macro feature but for that I would have to make a macro that launches another macro:SmartProperties 2014-Auto.swp and which is not in the same directory as the first macro
Example of the current directory of C:\Macro macros and smartproperties in C:\Smartproperties
I had found the same thing except RunMacro instead of RunMAcro2, I try that and then I come back to tell the result.
Otherwise how can I be sure that the person launches the macro by doing a macro feature because it launches manually for the 1st time if I understood correctly and then it launches itself with each modification see example macro center of gravity attached (but the code is locked by the author ->Axemble)
EDIT: for the properties to be updated they are multiple depending on the type of part
1-) Length and width of a sheet metal for sheet metal
2-) Strip length calculated according to the type of strip
- PVC = Lgbelt+4‰
- Modular = Lgbelt+100mm
- .....
3-) Designation that sometimes takes up some of the properties mentioned above
The macro itself works well, it launches, inserts the macro into the room tree, launches the smartproperties validates it. Then if you make the slightest modification of the coast it launches well on the other hand I have a problem depending on the method used it crashes.
If I modify a dimension and validate in the dialog box and then press Ctrl+Q or rebuild, no problem.
On the other hand, if I modify the dimension and rebuild in the dialog box before validating then the smartproperties crashes.
If anyone has an idea to get around this, the macro code is attached in the text file (impossible to put it in the answer because the answer is too long)
For the crash, maintenance has no idea, that's why I'm calling on the community!
Here is the response from the maintenance:
"The problem must be that we are trying to launch an AddIn and Solidworks must not like that while a macro feature is running."
For now I'm looking in the smartproperties trying to add a run property with option to wait for the end of the application or with update properties.
Hello; I allow myself to dig up this subject (7 years anyway)... it is possible to call the Smartproperties from another Macro (optionally usable with the Integration tool. In the Visiativ Tools Installation Directory: Search and edit (with the Solidworks Macro Editor) SmartProperties.swp Look for the ToolbarID and the number associated with "Set swDCAddIn = swApp.GetAddInObject"{...}")
Then to initialize and launch the Smartproperties:
Sub main()
Dim swApp As Object
Dim swModel As Object
Dim swDCAddIn As Object
Dim strDllFileName As String
Dim strExecutablePath As String
Dim strRegFileName As String
Dim lStatus As Long
Dim retval As Long
Dim ToolbarId As Long
On Error Resume Next
ToolbarId = ***Le N° du ToolBarID*** 'Attention, il faut recuperer le numero de la toolbar SmartProperties depuis la macro "Smarproperties_Auto.swp" la plus recente
'On récupére l'application SW
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
MsgBox ("Pas de document actif")
End
Else
Dim stPathMacro As String
stPathMacro = swApp.GetCurrentMacroPathName
strRegFileName = Replace(stPathMacro, "-Auto.swp", ".dll")
strDllFileName = strRegFileName
'on initialise l'Add-ins
lStatus = swApp.LoadAddIn(strDllFileName)
'on récupére l'Add-ins (Attention, il faut recuperer le numero de l'app SmartProperties depuis la macro "Smarproperties_Auto.swp" la plus recente)
Set swDCAddIn = swApp.GetAddInObject("{***XXXXX-XXX-XXXX***}")
....
'on lance SmartProperties
swDCAddIn.OpenAndValidateSmartProperties
End If
End Sub
Warning: the ToolBarID and AppSmarproperties Numbers change with each new update of the MyCad tools... (And their location too).