hi there,
i have a part file (1.sldprt), and there are 3 dimensions in this part (length_cubic@extrude, width_cubic@sketch1 and height_cubic@sketch1, a cubic with 3 dimensions actually). Besides, there is an assembly.
What i'm trying to do is, to add this part with different values of the 3 dimensions (as different configurations of this part) into the assembly. In other words, the assembly is composed by various configurations of this part file.
Here's the code:
********************************************************************************
Sub CreateAssembly( ... Byref m As Integer, Byref n As Integer, Byref dimension() As Double)
...
For i=0 to m
For j=0 to n
If ...... then
length=dimension(0)
width=dimension(1)
height=dimension(2)
component2=AddCom2Assembly(path, title, x, y, z, length, width, height)
end if
Next
Next
...
End Sub
Function AddCom2Assembly(ByVal path As String, ByVal assTitle As String, _
ByVal x As Double, ByVal y As Double, ByVal z As Double, _
ByVal length As Double, ByVal width As Double, ByVal height As Double) As Component2
......
Dim swconfigMgr As ConfigurationManager
Dim swConfig As Configuration
model = iSwApp.OpenDoc6(path, swDocumentTypes_e.swDocPART, swOpenDocOptions_e.swOpenDocOptions_Silent, "", 0, 0
model = SwApp.ActiveDoc
swconfigMgr = model.ConfigurationManager
Dim confName As String = CStr(length) + " * " + CStr(width) + " * " + CStr(height)
swConfig = swconfigMgr.AddConfiguration(confName, "comment", confName + "alterName", swConfigurationOptions2_e.swConfigOption_UseAlternateName, "", confName + "testaddingConfig")
swConfig = swconfigMgr.ActiveConfiguration
Dim swDim(3) As Dimension
swDim(0) = model.Parameter("length_cubic@extrude")
swDim(1) = model.Parameter("width_cubic@Sketch1")
swDim(2) = model.Parameter("height_cubic@Sketch1")
swDim(0).SetSystemValue3(length, swSetValueInConfiguration_e.swSetValue_InSpecificConfigurations, confName)
swDim(1).SetSystemValue3(width, swSetValueInConfiguration_e.swSetValue_InSpecificConfigurations, confName)
swDim(2).SetSystemValue3(height, swSetValueInConfiguration_e.swSetValue_InSpecificConfigurations, confName)
......
component = AssemblyDoc.AddComponent5
swApp.ActivateDoc(...) ' ***** save and close the part file
ModelDoc.Save3 ' *****(1.sldprt)
ModelDoc.CloseDoc
Return component
End Function
********************************************************************************
the problem is, everytime i can successfully add dimensions to the first configuration, but when j plus and enters into the next cycle, there will be a problem on this sentence:
swDim(0).SetSystemValue3
because swDim(0) is null.
Could someone tell me why ModelDoc2 can find length_cubic@extrude in the firstloop while cannot in the second loop?
Any comments will be appreciated.
Regards,
Shane