- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All
I'm trying to transfer multible reference parameters from a derived part to into User Parameters of a new part, and I have run into several issues.
1: How do I get the parameters from the derived part? I've tried this:
Dim Doc As Document
Set Doc = ThisApplication.ActiveDocument
Dim Params As Parameters
Set Params = Doc.ComponentDefinition.Parameters
Dim DerivedParamTbl As DerivedParameterTable
Set DerivedParamTbl = Params.DerivedParameterTables.Item("Path of the derived part") ' I geuss this is very bad practice, since I hoping to use this marco for any derived part I want in th future.
Dim DerivedParam As DerivedParameter
Set DerivedParam = DerivedParamTbl.DerivedParameters.Item("Length")
2: When I get the value of a numeric parameter, the value is scaled down by a factor 10 (the decimal jogs to the left - 100 becomes 10, 200 becomes 20 and so on). I'm having a message box write out the values, and it seems that the scaling talks place, when the value is retreived ( Please note, that the value in this case simply comes from another User Parameter. Since I'm not yet able to get the values from the derived parts referenced parameters, I'm just testing with User Parameters. See the attachements. I'm trying to transfer the values named CopyXXX to the ones called PasteXXX.). Another indication that the scaling takes place when the value is retrieved is that I can simply set the value in the "target parameter" by using a predefined interger variable. Please see the test code:
Sub MakeAbox()
Dim Doc As Document
Set Doc = ThisApplication.ActiveDocument
Dim Params As Parameters
Set Params = Doc.ComponentDefinition.Parameters
Dim UserParams As UserParameters
Set UserParams = Params.UserParameters
Dim PasteDimParam As Parameter
Set PasteDimParam = UserParams.Item("PasteDim")
Dim CopyDimParam As Parameter
Set CopyDimParam = UserParams.Item("CopyDim")
Dim PasteTxtParam As Parameter
Set PasteTxtParam = UserParams.Item("PasteTxt")
Dim CopyTxtParam As Parameter
Set CopyTxtParam = UserParams.Item("CopyTxt")
Dim PasteBoolParam As Parameter
Set PasteBoolParam = UserParams.Item("PasteBool")
Dim CopyBoolParam As Parameter
Set CopyBoolParam = UserParams.Item("CopyBool")
MsgBox CopyDimParam.Value & vbNewLine & CopyTxtParam.Value & vbNewLine & CopyBoolParam.Value
Dim SomeNumber As Integer
SomeNumber = 1523
'PasteDimParam.Expression = CopyDimParam.Value ' When using this line the Target parameter gets the scaled value
PasteDimParam.Expression = CopyDimParam.Value & " cm" ' When using this line the Target parameter gets the scaled value in the equation column, but gets "cheated" to set the right norminal value.
PasteDimParam.Expression = SomeNumber ' When using this line the Target parameter gets the variable "SomeNumber" holds.
'PasteTxtParam.Expression = CopyTxtParam.Value ' Gives me Run time error 5
PasteBoolParam.Expression = CopyBoolParam.Value
Doc.Update
End Sub
3: I can get a text parameter (check what the messages box says) , but I get a Run Time Error 5 when trying to "paste it" to the target parameter.
The purpose of making this is to quickly make a box design, with lid and bottom, with flat patterns for both depending on the bounding box of the derived part.
Any help will be appreciated.
Cheers - Anders
Solved! Go to Solution.