PDA

View Full Version : visual basic help?


petehouwen
01-30-2002, 10:49 AM
I am trying to set up an array of all of the decals in a library. It works,
but....

In a library with many parts (this one has 600+), this code runs
SSSSSLLLLOOOOWWW. It's OK if I only have a few decals. In the For...Next
loop, it sees objects at the rate of about 1 every 2 seconds. By then it has read the library, it's just the loop that is slow.

The code:

Function FillDecals (CurLib, DecFlt)
i=0
For Each libs In Libraries
If Libs.Name = CurLib Then
c = Libs.GetLibraryItems(ppcbLibraryItemTypeDecal,).Count
ReDim DecalArray(c)
Set items = Libs.GetLibraryItems(ppcbLibraryItemTypeDecal,DecFlt)
For Each item In items
DecalArray(i)= item.Name
i = i+1
Next item
End If
Next libs
End Function


Any ideas?

Bodhran1
02-04-2002, 04:45 PM
I'm new to VB Scripts too, but have you tried the "lock server" command set?


Good Luck!!!


Dave

petehouwen
02-05-2002, 06:01 AM
I did try the lock server, it didn't really help much.

I think I know what's happening. The GetLibraryItems command was working OK. But I think since that command builds a collection, not an array, the For..next actually had to read the entire collection each time. 600+ decals, all the lines, padstacks.... No wonder it took so long.

I was able to invoke the PADS library dialog box, and use that within the script to get to the decal I wanted to edit.

The script is finished. I am udating all of my libraries to add placement courtyards, ProE outlines, geometry.heigh attributes, moveable silkscreen text, and check layers and line widths. This script handles most of that automatically. When I have it debugged, I'll make it available.

Mark Larson
02-06-2002, 08:55 AM
I would really like to see it, I have a BOM to Excel generator that has the same problem. The script is for companies that use an attribute to place it's company part number rather than the part type. It places similar parts on the same line, just adds all the ref des together. It ignores any part without a part number so you don't get mounting holes, ... It works great but is slow for the same reason as yours, I'd like to speed it up. It currently takes an hour for the biggest board I've tried it on. Works great for boards with only a couple hundred parts though.

petehouwen
02-06-2002, 09:43 AM
I have a similar script. It was written before PADS supported visual basic. So the only was to do it was to write a BOM report from pads, then run the script in Excel to import and format.