hi!
i have created an assembly and i'm editing all the parts to havetheir equations, so first i have to open their equation managers.
i have tried with this code but it opens the equation manager ofthe modeldoc (=of the assembly):
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swEqnMgr As SldWorks.EquationMgr
Dim swDim As SldWorks.Dimension
Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
Set swEqnMgr = swModel.GetEquationMgr
Dim nCount As Integer, i As Integer, iPos As Integer
Dim a As String
nCount = swEqnMgr.GetCount
For i = 0 To nCount - 1
a = swEqnMgr.Equation(i)
Set swDim = swModel.Parameter(a)
Cells(k, 3) = swDim.FullName
the problem is that i active the modeldoc and i have to active thecomponent, so i turn the component into a modeldoc but itdoesn´t work:
.....
Dim c As SldWorks.ModelDoc2
Set c = swComp.GetModelDoc
Set swDim = swModel.Parameter(b)
Cells(k, 3) = swDim.FullName
can you help me?
thanks a lot!SolidworksApi macros
i have created an assembly and i'm editing all the parts to havetheir equations, so first i have to open their equation managers.
i have tried with this code but it opens the equation manager ofthe modeldoc (=of the assembly):
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swEqnMgr As SldWorks.EquationMgr
Dim swDim As SldWorks.Dimension
Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
Set swEqnMgr = swModel.GetEquationMgr
Dim nCount As Integer, i As Integer, iPos As Integer
Dim a As String
nCount = swEqnMgr.GetCount
For i = 0 To nCount - 1
a = swEqnMgr.Equation(i)
Set swDim = swModel.Parameter(a)
Cells(k, 3) = swDim.FullName
the problem is that i active the modeldoc and i have to active thecomponent, so i turn the component into a modeldoc but itdoesn´t work:
.....
Dim c As SldWorks.ModelDoc2
Set c = swComp.GetModelDoc
Set swDim = swModel.Parameter(b)
Cells(k, 3) = swDim.FullName
can you help me?
thanks a lot!SolidworksApi macros

Dim c As SldWorks.ModelDoc2
Set c = swComp.GetModelDoc
set a = c.GetEquationMgr
i have done like this and it works:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swAssy As SldWorks.AssemblyDoc
Dim swChildComp As SldWorks.Component2
Dim vChildComp As Variant
Dim swEqnMgr As SldWorks.EquationMgr
Dim swDim As SldWorks.Dimension
Dim c As SldWorks.ModelDoc2
Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
Set swAssy = swModel
Dim a As Boolean
Dim i As Integer
Dim nCount As Integer, j As Integer
Dim a As String
vChildComp = swAssy.GetComponents(False)
For i = 0 To UBound(vChildComp)
Set swChildComp = vChildComp(i)
a = swChildComp.Select3(True, Nothing)
swModel.EditPart
Set c = swComp.GetModelDoc 'component --> modeldoc
Set swEqnMgr = c.GetEquationMgr
nCount = swEqnMgr.GetCount
For j = 0 To nCount - 1
a = swEqnMgr.Equation(i)
Set swDim = c.Parameter(a)
Cells(k, 3) = swDim.FullName