How to create surfaceBody from list of faces and read volume of this surfaceBody

How to create surfaceBody from list of faces and read volume of this surfaceBody

dariuszm
Advocate Advocate
621 Views
4 Replies
Message 1 of 5

How to create surfaceBody from list of faces and read volume of this surfaceBody

dariuszm
Advocate
Advocate

Hello,

 

I would like to read volume of collection of faces. How to create surfaceBody from list of faces and read volume of this surfaceBody?

0 Likes
622 Views
4 Replies
Replies (4)
Message 2 of 5

JelteDeJong
Mentor
Mentor

Im not exactly sure how you want to select the surfaces so this rule will select them all.

 

Dim doc As PartDocument = ThisDoc.Document
Dim features As PartFeatures = doc.ComponentDefinition.Features

Dim patchFeatures = features.BoundaryPatchFeatures

Dim surfaces As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

For Each item As WorkSurface In doc.ComponentDefinition.WorkSurfaces
    surfaces.Add(item)
Next

Dim oKnitFeature As KnitFeature = features.KnitFeatures.Add(surfaces)

Dim volume = oKnitFeature.SurfaceBodies.Item(1).Volume(0.1)
MsgBox(volume & " cm^3")

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 5

dariuszm
Advocate
Advocate

Thank you for this. My intention is to collect information about Weld Bead and get all faces of this bead. After this I would like to build transient solid body (same as this bead model) and get a Volume of this transient solid body (or surface body).

 

Can you help me with this? Do you need any sample file with example weld beads?

0 Likes
Message 4 of 5

JelteDeJong
Mentor
Mentor

If you really want the "transient solid body" this is possible but I expect that you are most interested in the volume. This information can be extracted much easier like this:

Dim doc As AssemblyDocument = ThisDoc.Document
Dim curent As ComponentOccurrence = Nothing
Dim totalVolume = 0.0
Do
    curent = ThisApplication.CommandManager.Pick(
        SelectionFilterEnum.kAssemblyOccurrenceFilter,
        "Select weldbeats (Press esc when all beats are selected.")
    If (curent IsNot Nothing) Then
        Dim beadVolume = curent.SurfaceBodies.Item(1).Volume(0.1)
		Logger.Info(String.Format("{0}: {1}cm^3", curent._DisplayName ,beadVolume))
        totalVolume = totalVolume + beadVolume
    End If

Loop Until curent Is Nothing


Logger.Info(String.Format("Total: {0}cm^3", totalVolume))

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 5

dariuszm
Advocate
Advocate

Hi, I would like to build my own surface body, because in modele there can be more than one weld bead, but unfortunately Autodesk do all welds in assembly as single solid/surface body. I want to have information about each weld bead volume in assembly. I can get faces from weld bead and base on this info I will build my own surface body (and read volume). 

0 Likes