Hi all, i need a line of code that will count the components within an assembly whilst ignoring any suppressed or hidden parts. Any help would be highly appreciated.
Use this example: Get and select all visible components in assembly using SOLIDWORKS API . Just modify it slightly. Instead of selection
swAssy.Extension.MultiSelect2 vComps, False, Nothing
MsgBox UBound(vComps) + 1
This has worked like a dream,
On a separate note, is there a way i can alert a user if a part within an assembly is missing a drawing?
Not really... Parts and assemblies do not "know" that they are used in drawings. Only the drawing "knows" that it uses the part/assembly. If you have a standardized way of saving your files (e.g. drawing same name as part, always same directory, etc.) you can use the File System Object (google it) to look for specific files. If you want to get really fancy, you can search for all drawing files and use the Document Manager API to examine each one and see if it references the parts. However, that's not super straightforward, so it's kinda one of those things where if you had to ask if it's possible, you probably have a lot to learn before you would actually be able to do it.
I have used fso before but will i be able to use that to cycle through all the parts within an assembly and then at the end use a message box to alert the user? For example, say i have an assembly with 5 parts. Part 1 and 2 do not have an associated drawing, however part 3,4 and 5 have a drawing saved within the same directory as both the part file and the assembly. Is there a way to use a message box to tell the user "Part 1 and Part 2 do not have a drawing" My thinking would be to create a loop where the code goes through the assembly and gets each part, checks if it has a drawing, if it doesn't, then add the part name to a string which will later be shown using a message box. I just dont know how to implement that method.
It's certainly possible. Elementary even. Best of luck!
Is it possible for you to give me a nudge in the right direction? Or if i show you my current script if you can tell me if im near?
Retrieving data ...