I have created a macro that controls a building with a user form. apon starting the macro I would like to get the current values (dimensions in the design sketches) and assign them to the text boxes in the user form.
Hi Gerard, on the Load event of your from, just set your textbox text property equal to the dimension value.
Dim swDoc as Modeldoc2
TextBox1.Text = swDoc.Parameter("D1@Sketch1").Value
Made a macro for linking dims to a custom property some time ago.
Cleaned that up and here is some code you might have a look:
Feel free to modify.
This macro is for parts only.
Best regards, TapaniS
PS. Use Instant 3D-button to get dims visible while clicking to a model.
I tried Filipe code first and it worked well, though thanks for your response Tapani
Thanks for the help
I tried adding those line to the Private Sub UserForm_Initialize(), but I got a error code 91,
"Object variable or with Block variable not set"
Then I replaced "swDoc" to "part" and the line worked perfect
thanks again for your help.
Well done, good catch!
You can just as easily set values to a dimension/parameter as well...like so:
value = Part.Parameter("D1@Sketch1").Value
Regards, and good luck!
Retrieving data ...