ASSEMBLING PART CONFIGURATIONS WITH MACROS

I have created thausand of configurations out of a single SW part driven by a design table. Now I would like to automate the process of inserting those part configurations into a assembly file by running a macro. Is it possible? I will appreciate your advice. regards, Ariel

Reply to
Ariel
Loading thread data ...

Some of the access to configuration control of components in an assembly are limited. This may be one of those areas.

Try recording a macro and see what you get.

Reply to
TOP

I recorded a macro as Mr. TOP suggested, I inserted 3 different configurations and saved the steps, however the result was not very happy, the macro inserts the same configuration 3 times, Does it mean that SW API can not control part configurations? Please let me know what you think. Ariel

Reply to
Ariel

FYI - I believe that parts with thousands of configurations can lead to very bad performance in large assemblies. I don't know off the top of my head, but maybe someone with more experience can chime in.

As for adding the configuration. The API you want is: retval = AssemblyDoc.AddComponent4 ( compName, configName, x, y, z)

See that the second parameter is configName. Just specify that and the proper configuration will be inserted.

Reply to
Mr. Who

That is the limitation. It's been around since 2003 and probably before. As Mr. Who said, multi-config parts in a large assembly can slow things down.

Reply to
TOP

I am looking for a person who is able to write the above mentioned macro. If you are interested please let me know. then we can discuss about the specifics... Ariel

Reply to
Ariel

Is this a size thing (i.e. diameter of a shaft changes to the receptacle hole)? Do you have 2006? If yes to both then lookup smart components, you may be able to do this yourself.

Ben

Reply to
Ben Eadie

Mr. Who I have this litle macro that intents to insert a part configuration (#100 as you can see in the macro) do you know why it does not work? how do I tell SW to insert the configuration number 100?? I will really appreciate your help!!!!!!!!!!!!Then i will create a loop for the macro to insert thousands of configurations, this is my ultimate goal. Ariel

Dim swApp As Object Dim Part As Object Dim SelMgr As Object Dim boolstatus As Boolean Dim longstatus As Long, longwarnings As Long Dim Feature As Object Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc Set SelMgr = Part.SelectionManager AssemblyDoc.AddComponent4 "K:\47200_20_Fenchurch_St\C_Product\10_Models\10A_Virtual\3dm\2006_03\AD\CW UNIT\CW UNIT L2.SLDPRT", 100 End Sub

Reply to
Ariel

Mr. Who I have this litle macro that intents to insert a part configuration (#100 as you can see in the macro) do you know why it does not work? how do I tell SW to insert the configuration number 100?? I will really appreciate your help!!!!!!!!!!!!Then i will create a loop for the macro to insert thousands of configurations, this is my ultimate goal. Ariel

Dim swApp As Object Dim Part As Object Dim SelMgr As Object Dim boolstatus As Boolean Dim longstatus As Long, longwarnings As Long Dim Feature As Object Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc Set SelMgr = Part.SelectionManager AssemblyDoc.AddComponent4 "K:\47200_20_Fenchurch_St\C_Product\10_Models\10A_Virtual\3dm\2006_03\AD\CW UNIT\CW UNIT L2.SLDPRT", 100 End Sub

Reply to
Ariel

What you are describing now and what you described earlier are different. Initially you said you wanted to insert a part into an assembly using a specified configuration. "I would like to automate the process of inserting those part configurations into a assembly file ."

Now you are saying that you want to insert a new configuration into a part. "I have this litle macro that intents to insert a part configuration "

To insert configuration "100" of a file called "PathToPart.sldprt" at the assembly origin you would use: AssemblyDoc.AddComponent4 ( compName, configName, x, y, z) AssemblyDoc.AddComponent4 "pathToPart.sldprt", "100", 0, 0, 0 (insert at origin of assembly)

To add a configuration to a part called "100" you would use: ModelDoc2.AddConfiguration3 ( Name, Comment, AlternateName, Options ) PartDoc.AddConfiguration3 "100", "", "", 0

Reply to
Mr. Who

Ariel,

Reply to
Tin Man

Mr Who I appreciate your help a lot. It is being really helpful. What I need is To insert configuration "100" of a file called "PathToPart.sldprt" at the assembly, however I do not want to insert the confguration at the assembly 0,0,0, the part should be inserted according to its own original position, otherwise nothing would work for me.I have thousands of windows configurations, each of them has a unique shape and position in space since they cover a free-form building curtain-wall.

Both, the building wireframe I am using as support and the configurations share the same 0,0,0... Regards, Ariel

Reply to
Ariel

Hmmm, so you have lots of windows and need to place them into the assembly at specific locations.

What do you mean by "part should be inserted according to its own original position." What data do you have available so that you know what x,y,z points to use for inserting the component?

Reply to
Mr. Who

Mr. who I have created a generic window (a part) that has 4 corners. each corner position (xyz) is control by a design table, meaning that each windows needs 12 values (4 corners*3 values per corner=12). Each of thiese corners has 3 dimensioanl contrains related to the 0,0,0. So the design table is fill out with rows of 12 numbers that control each window corner. If I wanted to create the assembly manually, I just would insert each configuration one by one (as you can imagine it would a insane task). I use insert new componet, then i selectt the part, then i select the configuration, and then I click OK, so the configuration flys to the right position automatically.

So the keypoint is to create a macro that takes each window coordinates into consideration. May be it could use the design table to drive the windows, (i am wondering) THANK YOU!!!!

Reply to
Ariel

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.