I recorded a macro and then used the code.
I can change one dimension only. It comes up with error when there are more than 1 dimension is selected
That's because a program does exactly what it is designed for and nothing more. If it should handle single and multiple selected items, the code should be changed so it can handle that. In this case you should probably add a check to make sure every selected item is a dimension and then create a "for" loop that changes each selection item.
What do you have now?
In my case I need include the tolerance value for each and every dimension but the dimension has different tolerance values.
So I need to enter the tolerance values in textbox using Userform. I already created a Userform to edit the dimension and the codes are as below,
Can you please help me on this a?
Dim swApp As ObjectDim Part As ObjectDim boolstatus As BooleanDim longstatus As Long, longwarnings As LongDim dblDiameter1 As DoubleDim dblLength1 As DoubleDim dblRadius2 As DoubleDim dblangle2 As DoublePrivate Sub cmd1_Click()
Set swApp = Application.SldWorksSet Part = swApp.OpenDoc6("File Location", 1, 0, "", longstatus, longwarnings)swApp.ActivateDoc2 "File Name", False, longstatus
dblDiameter1 = CDbl(txtOD1.Text * (25.4 / 1000))dblLength1 = CDbl(txtLEN1.Text * (25.4 / 1000))dblRadius2 = CDbl(txtR2.Text * (25.4 / 1000))dblangle2 = CDbl(txtANGLE2.Text * (3.14159265358979 / 180))Set swApp = Application.SldWorksSet Part = swApp.ActiveDocPart.Parameter("D1@Sketch1").SystemValue = dblDiameter1Part.Parameter("D5@Sketch1").SystemValue = dblLength1Part.Parameter("D1@Outer").SystemValue = dblRadius2Part.Parameter("D4@Sketch1").SystemValue = dblangle2Part.EditRebuildPart.ClearSelection2 TruePart.ViewZoomtofit2End Sub
Retrieving data ...