Costin Ruja
Electrical
Good morning all !
So I made some formula (with the help of you guys) to measure some splines.It works perfectly but now I need to somehow automate the process.Not really knowing programming and stuff I just pushed the record macro button and all seemed OK. I just need to fill in the Part Description field with this formula:
"L="+ToString((1+int(((MeasureEdge.1\Length/1mm)+15/100*(MeasureEdge.1\Length/1mm))/50))*50)+"mm"
With the script that Catia has recorded, the output is like this
Language="VBSCRIPT"
Sub CATMain()
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim relations1 As Relations
Set relations1 = part1.Relations
Dim parameters1 As Parameters
Set parameters1 = part1.Parameters
Dim parameter1 As Parameter
[highlight #EF2929]Set parameter1 = parameters1.Item("1510005-L1-504\Product Description")[/highlight]
Dim formula1 As Formula
Set formula1 = relations1.CreateFormula("Formula.2", "", parameter1, "" & """" & "L=" & """" & "+ToString((1+int(((MeasureEdge.2\Length/1mm)+15/100*(MeasureEdge.2\Length/1mm))/50))*50)+" & """" & "mm" & """" & "")
formula1.Rename "Formula.2"
End Sub
The error is in line 18, I think because this line contains the name of the part in which the script was recorded.
How can I get rid of this error and make the macro working for arbitrary parts ?
Have a nice weekend,
Costin
Best regards,
Costin Ruja
So I made some formula (with the help of you guys) to measure some splines.It works perfectly but now I need to somehow automate the process.Not really knowing programming and stuff I just pushed the record macro button and all seemed OK. I just need to fill in the Part Description field with this formula:
"L="+ToString((1+int(((MeasureEdge.1\Length/1mm)+15/100*(MeasureEdge.1\Length/1mm))/50))*50)+"mm"
With the script that Catia has recorded, the output is like this
Language="VBSCRIPT"
Sub CATMain()
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim relations1 As Relations
Set relations1 = part1.Relations
Dim parameters1 As Parameters
Set parameters1 = part1.Parameters
Dim parameter1 As Parameter
[highlight #EF2929]Set parameter1 = parameters1.Item("1510005-L1-504\Product Description")[/highlight]
Dim formula1 As Formula
Set formula1 = relations1.CreateFormula("Formula.2", "", parameter1, "" & """" & "L=" & """" & "+ToString((1+int(((MeasureEdge.2\Length/1mm)+15/100*(MeasureEdge.2\Length/1mm))/50))*50)+" & """" & "mm" & """" & "")
formula1.Rename "Formula.2"
End Sub
The error is in line 18, I think because this line contains the name of the part in which the script was recorded.
How can I get rid of this error and make the macro working for arbitrary parts ?
Have a nice weekend,
Costin
Best regards,
Costin Ruja