Using a dimension of a part to pull a part into an assembly

This is a bit of a long shot but here goes nothin... I am trying see if it is possible to have solidworks look at a diameter dimension of a
round pocket in a part that is in an assembly, then go pull the corresponding part out of a library that matches that diameter of the part pocket... these diameters change depending on the stock object we want to put into those pockets... I am trying to automate our design some by using a VBA macro inside Excel to control the assembly... i can make the assembly grow, shrink, do whateever i want, except the insert the components for me part... If my above description doesn't make sense, i will try to clarify... Any help you guys can give, would be great... Thanks in advance...
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Look at Smart Components - might be just exactly what you are looking for. One example of the usage is to have a shaft of a given diameter, pull in a snap ring that sizes itself to the size of the shaft, and then it in turn puts the proper size groove in the shaft.
WT

*** Free account sponsored by SecureIX.com *** *** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Bottom line is that you need configurations, not separate parts, if at all possible.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
As long as will you know the filename you want to insert, you can do it. The way that pops into my mind would be to name the files in a standard way (with the dimension in there). So maybe you have a 0.250-SHAFT.SLDPRT, 0.500-SHAFT.SLDPRT, 0.750-SHAFT.SLDPRT, and a 1.000-SHAFT.SLDPRT. Then if your dimension is X.XXX, you could concate the filename such that the macro inserts X.XXX-SHAFT.SLDPRT. Or even have some sort of lookup table that tells you for each dimension, which file to insert. That would work fine too.
If you wanted SW to actually open those other files and measure something there then close the file, and keep doing this over and over until it found a matching dimesion...I'd guess you could do that too but it'd probably be pretty slow. It'd be a lot faster to put that value in as a file property because you can access those without opening the files in SW.
Ken
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Thanks guys for your help so far...
Ken, how do i go about setting up a macro that do the if dimension is "x.xx" then the macro inserts x.xxx-shaft.sldprt... I am not having much luck finding adequate examples to steal stuff out of :) Also, how do you create a look up table? thats definitely what i am looking to do, just dont know where to look or start to get my dreams to come true... thanks again...
Jeff
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
You should check out DriveWorks to do what you want (www.driveworks.co.uk). It's perfect for this kind of stuff.
However, assuming your model is not that complicated, I also think configurations are the way to go. Maybe your excel macro could have a lookup table that chooses the name of a configuration based on your dimensional input?
You could still drive the dimension based on your spreadsheet (update a specific dimension) but the configuration would control the "state" of the parts and mates (supressed/unsuppressed)
As far as lookup tables are concerned, they're pretty easy once you do one or two.
The common command for the lookup table is :
=VLOOKUP([lookup_value],[data_range],[return_column],[boolean])
What this function does is finds a value (lookup_value) in the leftmost column of data_range. If it finds the value, it will return the value of the cell in that row which is return_column number of columns away from the first column.
I'll e-mail you an example.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
I have tried the driveworks that came with 2006, seems to work pretty good, just cant find good documentation and tutorials... the VLOOKUP looks like a viable option... I get want it does, but i cant figure out what code to put in the cell that is recalled by the vlookup so that it goes and gets the part or assembly i am looking for.... i am making my head hurt thinking about this stuff, and its a friday, i must be sick... any additional help or pointers would be great... thanks again...
Jeff
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Kinda hard to tell you waht to do without knowing more about what you're attempting to accomplish.
My thought was that you would populate the "data" field (for your lookup) with configuration names, which would coorespond with the type of data in the 2 dimensional array (for example, length x diameter). Dunno?
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Jeff, I hope the below gets you a push in the right direction. Ken
To Insert a component named MySlotWashers into the assembly: Set MySWComponent = swApp.OpenDoc6(MySlotWashers, swDocPART, swOpenDocOptions_Silent, "", fileerror, filewarning) Set MySWAssembly = swApp.ActivateDoc2(MySWAssembly.GetPathName, False, nErrors) Set NewComponentID = MySWAssembly.AddComponent4(MySlotWashers, MySlotWasherConfig, 0, 0, 0)
To Add a Coincident Mate: 'Coincident Mate MySWAssembly.ClearSelection2 True boolstatus = EntityArray(1).Select4(True, swSelData) boolstatus = MySWAssembly.Extension.SelectByID("Bottom Mate Plane@" & NewComponentID.Name2 & "@" & MySWAssemblyName, "PLANE", 0, 0, 0, True, 0, Nothing) Set SWFeature = MySWAssembly.AddMate2(0, 0, False, 0, 0, 0, 0, 0, 0, 0, 0, longstatus)
As for the Lookup Table statement, I think I should have used a different term. Yes Excel has a native lookup function that would work just fine, but I would recommend *not* involving Excel in this mix unless you have to because you're just adding more complexity (that I think you don't need to get into for this project). For now (or maybe at least for starters), just keep all the code and conditional stuff inside your macro. The lookup I was talking about was something along the lines of:
Sub main () Set swApp = CreateObject("SldWorks.Application") Set MySWAssembly = swApp.ActiveDoc
<<<All your code to read in the dimension value, I'll call it DimVal>>>
'Poor man's Lookup Table to get Filename of Component to Insert into Assembly Dim MyInsertComponentFilename as String If DimVal = 0.250 Then MyInsertComponentFilename = "0.250-SHAFT.SLDPRT" ElseIf DimVal = 0.500 Then MyInsertComponentFilename = "0.500-SHAFT.SLDPRT" ElseIf DimVal = 0.750 Then MyInsertComponentFilename = "0.750-SHAFT.SLDPRT" ElseIf DimVal = 1.000 Then MyInsertComponentFilename = "1.000-SHAFT.SLDPRT" Else MsgBox "Error. Filename for " & DimVal & " Not Found." End End If
<<< Stuff to Insert and Mate your Component, or whatever you you want to do. >>>>
End Sub
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
This code can also be written with the "Select" command in vb - does exactly the same thing, but sometimes makes more sense (to me anyways)
rewritten...
Dim MyInsertComponentFilename as String
Select Case DimVal
Case 0.250 MyInsertComponentFilename = "0.250-SHAFT.SLDPRT" Case 0.500 MyInsertComponentFilename = "0.500-SHAFT.SLDPRT" Case 0.750 MyInsertComponentFilename = "0.750-SHAFT.SLDPRT" Case 1.000 MyInsertComponentFilename = "1.000-SHAFT.SLDPRT" Case Else MsgBox "Error. Filename for " & DimVal & " Not Found." End Select
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Thanks for all of your help guys... I will see what happens when I implement this... Thanks again...
Jeff
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.