Thanks James,
I used the collection because it's the only way I could find to store
data,
and not having to know in advance it's size.
Putting it all in an array would mean, I need to got through the
collections
anyways.
"James Belshan" <jlbelshan@yahoo.com> a écrit dans le message de news:
41b73f96$1_1@newsprd01...
The collections are the slow part of your code.
Here's moderate improvement, by not having to reference the TRI
collections
so often.
Code:
Dim t1 As Long, t2 As Long, t3 As Long
For i = 1 To CntTri - 1
t1 = Tri1.Item(i)
t2 = Tri2.Item(i)
t3 = Tri3.Item(i)
FacePt1(0) = VtxX.Item(t1)
FacePt1(1) = VtxY.Item(t1)
FacePt1(2) = VtxZ.Item(t1)
FacePt2(0) = VtxX.Item(t2)
FacePt2(1) = VtxY.Item(t2)
FacePt2(2) = VtxZ.Item(t2)
FacePt3(0) = VtxX.Item(t3)
FacePt3(1) = VtxY.Item(t3)
FacePt3(2) = VtxZ.Item(t3)
Set Obj3DFace = ThisDrawing.ModelSpace.Add3DFace(FacePt1, FacePt2,
FacePt3, FacePt1)
Next
If you can make collections of user-defined-types (I don't know about
this),
you could further reduce the number of calls to collections by having a
collection of UDT's so a single call to the collection gets an X,Y, and
Z
value:
Code:
Type Point3Data
x As Double: y As Double: z As Double
End Type
Dim Pt3 as Point3Data
Pt2 = Vtx.Item(t2)
FacePt2(0) = Pt2.x
FacePt2(1) = Pt2.y
FacePt2(2) = Pt2.z
Pt3 = Vtx.Item(t3)
FacePt3(0) = Pt3.x
FacePt3(1) = Pt3.y
FacePt3(2) = Pt3.z
Lastly, the quickest code, IMO, would be to copy your collections into
arrays before running your loop. Using arrays would be fast with 11000
items. I know arrays are going out of style, so maybe someone can
disprove
this point....
James
"Yves" <EvenHere@ThereIsTooMuchSpam.com> wrote in message
news:41b712d2_3@newsprd01...
Hi, I have a very simple code that reads an ASCII file to extract
Points,
and triangles formed with the points.
The file I'm working on has about 11000 triangles that I want to form
3dFaces with.
(in case someone knows this product I read a Gocad file, which is slow
to
DXFOUT)
First I load all the points into a collection, then all the triangles.
I use this code to retreive the triangles and create them, but it takes
about 5 min on a 1.5Gb Ram, 2.4Mhz computer.
The ASCII file is read in about 2 seconds.
Someone can help me speed up this thing.