Finding the center of volume of an assembly without using Save As Part

laukejas
Posts: 133
Joined: Sun Sep 05, 2021 8:27 am
Answers: 0
x 33
x 84

Finding the center of volume of an assembly without using Save As Part

Unread post by laukejas »

Hi, I am looking for a parametric method to check the precise coordinates of the center of volume of an assembly. I googled around, and the usual suggestion is to save assembly as a multibody part, so that all bodies have the same material, hence center of mass is in the same spot as center of volume. Issue is, with a large assembly and a lot of components, Save As Part takes forever (~700 component assembly takes around 40 minutes to be saved as a part on my PC).
I tried a macro that temporarily changes material of every part in the assembly, checks CoM and then restores the materials - I didn't get it to work reliably (it often messes up configurations, etc.), and even when it does work, changing material for so many parts (there are a lot of unique parts) takes ~10-15 minutes.
I also tried to write a macro that creates a temporary body copy of every component in the assembly (temporary bodies are disassociated from materials), and measure their combined CoM. But again, making that many copies takes even longer than changing material.
And I also tried writing a macro that checks CoM of every individual component, and then does the math without using SOLIDWORKS API to weigh volume of each component and it's CoM coordinates to get center of volume for the entire assembly. But even this is unacceptably slow, as getting CoM data from every component takes a lot of time with so many components.

Can someone suggest a better way? SW calculates assembly CoM coordinates very quickly, so I really doubt it interrogates every single part for it's CoM data to make a combined CoM. I feel like there's got to be a faster way to get that center of volume in a similar way.
User avatar
AlexLachance
Posts: 2032
Joined: Thu Mar 11, 2021 8:14 am
Answers: 17
Location: Quebec
x 2187
x 1887

Re: Finding the center of volume of an assembly without using Save As Part

Unread post by AlexLachance »

Export as parasolid or another filetype for data exchange and then use the generated file to create your part.


Just thinking off the top of my head.
laukejas
Posts: 133
Joined: Sun Sep 05, 2021 8:27 am
Answers: 0
x 33
x 84

Re: Finding the center of volume of an assembly without using Save As Part

Unread post by laukejas »

AlexLachance wrote: Thu Feb 09, 2023 2:48 pm Export as parasolid or another filetype for data exchange and then use the generated file to create your part.


Just thinking off the top of my head.
Trying it now - parasolid export and import is fast, but it is still imported back as an assembly. Tried inserting that Parasolid into a part - got error "Assembly file detected. Import not allowed". Tried the same with STEP files - same result, but much slower. If you know a way to get this to work, let me know.
User avatar
AlexLachance
Posts: 2032
Joined: Thu Mar 11, 2021 8:14 am
Answers: 17
Location: Quebec
x 2187
x 1887

Re: Finding the center of volume of an assembly without using Save As Part

Unread post by AlexLachance »

laukejas wrote: Thu Feb 09, 2023 3:18 pm Trying it now - parasolid export and import is fast, but it is still imported back as an assembly. Tried inserting that Parasolid into a part - got error "Assembly file detected. Import not allowed". Tried the same with STEP files - same result, but much slower. If you know a way to get this to work, let me know.
Do you have 3D Interconnect checked? If so, then uncheck it and have the parasolid be exported. You should then be able to save it as a part. I've never had an issue with saving .step or .igs or anything else as a part. The issues I have are generally with opening the file.
User avatar
josh
Posts: 261
Joined: Thu Mar 11, 2021 1:05 pm
Answers: 11
x 19
x 453

Re: Finding the center of volume of an assembly without using Save As Part

Unread post by josh »

These settings (particularly the circled one) should let you import the parasolid as a multibody part.
image.png
You probably want to set this option for the export as well:
image.png
laukejas
Posts: 133
Joined: Sun Sep 05, 2021 8:27 am
Answers: 0
x 33
x 84

Re: Finding the center of volume of an assembly without using Save As Part

Unread post by laukejas »

AlexLachance wrote: Thu Feb 09, 2023 3:39 pm Do you have 3D Interconnect checked? If so, then uncheck it and have the parasolid be exported. You should then be able to save it as a part. I've never had an issue with saving .step or .igs or anything else as a part. The issues I have are generally with opening the file.
I tried with and without Interconnect. Doesn't seem to make a difference for the structure...
josh wrote: Thu Feb 09, 2023 4:07 pm These settings (particularly the circled one) should let you import the parasolid as a multibody part.

You probably want to set this option for the export as well:
I think these settings don't break down assemblies, only separate multibody part bodies into different parts. I tried it though - still the same, parasolid is imported as an assembly, only every component dissolved into a separate part. Saving that assembly as a part still takes 40 mins.
User avatar
Frederick_Law
Posts: 1842
Joined: Mon Mar 08, 2021 1:09 pm
Answers: 8
Location: Toronto
x 1547
x 1396

Re: Finding the center of volume of an assembly without using Save As Part

Unread post by Frederick_Law »

Once you import the parasolid, everything is same material.
So CoG should be center of volume.
Why do you need center of volume? What are you calculating?
laukejas
Posts: 133
Joined: Sun Sep 05, 2021 8:27 am
Answers: 0
x 33
x 84

Re: Finding the center of volume of an assembly without using Save As Part

Unread post by laukejas »

Frederick_Law wrote: Thu Feb 09, 2023 5:19 pm Once you import the parasolid, everything is same material.
So CoG should be center of volume.
Why do you need center of volume? What are you calculating?
Damn, you're right... I totally missed this obvious thing. In that case, even simple export to Parasolid works, and can be done in under a minute. I am designing an ROV (underwater drone), and I'm trying to balance center of gravity over center of buoyancy as I'm moving stuff around in the assembly, to minimize weights required to trim it after it is manufactured. It would be really cool to see that center of volume in real time, like with CoM. But exporting and opening Parasolid will have to do. It is still much better than Save As Part :D Thanks a lot, everyone!
User avatar
Frederick_Law
Posts: 1842
Joined: Mon Mar 08, 2021 1:09 pm
Answers: 8
Location: Toronto
x 1547
x 1396

Re: Finding the center of volume of an assembly without using Save As Part

Unread post by Frederick_Law »

You could use a config with only outside surface.
Buoyancy don't carry components inside. Only where ever water touch.
laukejas
Posts: 133
Joined: Sun Sep 05, 2021 8:27 am
Answers: 0
x 33
x 84

Re: Finding the center of volume of an assembly without using Save As Part

Unread post by laukejas »

Frederick_Law wrote: Thu Feb 09, 2023 6:28 pm You could use a config with only outside surface.
Buoyancy don't carry components inside. Only where ever water touch.
Yes, I'm very well aware of that. I model air inside the compartments as well (virtual components) to account for that.

Ok, I messed around with macros a bit more, and I found a way to optimize one of the initial ideas - macro that checks CoG of each part, and weights it against component's volume rather than mass, and combines weighted values to obtain total center of volume of the assembly. I found some tricks to reduce API calls, and managed to get that macro working in under 6 seconds for my 700 part assembly. Attaching it in case someone needs it.

What the macro does:
1) Finds the total Center of Volume of the assembly, excluding suppressed components;
2) Creates a sketch "CoV" with a single point that is like a marker for that CoV;
3) If that sketch and point already exists, it moves it rather than re-creating it, so that point can be used for drawings/whatever and updated without breaking references.
Attachments
Draw CoV.swp
(85.5 KiB) Downloaded 40 times
Post Reply