threepoints
Automotive
Dear all:
I plan to make a VBA macro for rutine works for me.
The structure:
Product
└Part1(fix)
└Part2
└constraints
some constraints are exist with Part2.
There are some parameters control by VBA, and send to Part1 and Part2
(basically are rnd() values, I check CATIA fomula and can't find random function)
example:
=======================================================================
Private Sub runanalysis_Click()
Dim StartTime As Date, EndTime As Date
StartTime = Timer
Set productDocument1 = CATIA.Documents.Item("Product1.CATProduct")
Set product1 = productDocument1.Product
Set documents1 = CATIA.Documents
Set partDocument1 = documents1.Item("Part1.CATPart")
Set XXX = partDocument1.Part
Set para1 = XXX.Parameters
Dim lh_h1_rnd As Length
Set lh_h1_rnd = para1.Item("lh_h1_rnd")
For i = 1 To 1000
lh_h1_rnd.Value = Rnd() * 10
product1.Update
'store a parameter to an array()
Next i
'export the array() data to EXCEL.
EndTime = Timer
MsgBox "Calculate total" & Format(EndTime - StartTime, "00:00") & "seconds"
End Sub
=======================================================================
From my previous experience, the macro will run slower and slower when loop cycles increases.
My question is:
1. Any suggestion for speed up CATIA loop macro?
2. Any VBA function can clean CATIA buffer or ...etc, and CATIA can reset?
3. I have another idea that could I run 100 loops, then close CATIA, re-open, run again. But how to write this automatically.
Thanks everyone....
3PTs from Taiwan
I plan to make a VBA macro for rutine works for me.
The structure:
Product
└Part1(fix)
└Part2
└constraints
some constraints are exist with Part2.
There are some parameters control by VBA, and send to Part1 and Part2
(basically are rnd() values, I check CATIA fomula and can't find random function)
example:
=======================================================================
Private Sub runanalysis_Click()
Dim StartTime As Date, EndTime As Date
StartTime = Timer
Set productDocument1 = CATIA.Documents.Item("Product1.CATProduct")
Set product1 = productDocument1.Product
Set documents1 = CATIA.Documents
Set partDocument1 = documents1.Item("Part1.CATPart")
Set XXX = partDocument1.Part
Set para1 = XXX.Parameters
Dim lh_h1_rnd As Length
Set lh_h1_rnd = para1.Item("lh_h1_rnd")
For i = 1 To 1000
lh_h1_rnd.Value = Rnd() * 10
product1.Update
'store a parameter to an array()
Next i
'export the array() data to EXCEL.
EndTime = Timer
MsgBox "Calculate total" & Format(EndTime - StartTime, "00:00") & "seconds"
End Sub
=======================================================================
From my previous experience, the macro will run slower and slower when loop cycles increases.
My question is:
1. Any suggestion for speed up CATIA loop macro?
2. Any VBA function can clean CATIA buffer or ...etc, and CATIA can reset?
3. I have another idea that could I run 100 loops, then close CATIA, re-open, run again. But how to write this automatically.
Thanks everyone....
3PTs from Taiwan