Automatically Thicken all faces on all solid bodies in part file.

Automatically Thicken all faces on all solid bodies in part file.

marius.andersen3RVB4
Enthusiast Enthusiast
165 Views
1 Reply
Message 1 of 2

Automatically Thicken all faces on all solid bodies in part file.

marius.andersen3RVB4
Enthusiast
Enthusiast

Hi.

Issue.
3D-Printing scaled steel constructions is not possible because objects are getting to thin.
Imagine printing a 6mm plate in scale 1:100.
Ohh. That`s trouble.

Manually move faces / thicken object is way to time consuming.

What i need
I need a code in iLogic that can iterate through all solid body faces in the part file and and thicken them with a given thickness (User input)

Faces should be moved along their positive normal vector

This is a well known issue in 3D-Printing world.
If someone can make this quick time-saving solution for this.....
He would be the hero off the day.

...
I know the model will not be accurate after printing, but still its scaled down so i don`t think it will matter.

0 Likes
166 Views
1 Reply
Reply (1)
Message 2 of 2

Michael.Navara
Advisor
Advisor

This is the first approach which can show you how to achieve this goal. It needs to be improved but for beginning...

 

 

Sub Main()
    Dim doc As Document = ThisDoc.Document
    Select Case doc.DocumentType
        Case DocumentTypeEnum.kAssemblyDocumentObject
            Dim asm As AssemblyDocument = ThisDoc.Document
            ThickenAssembly(asm, 0.1)

        Case DocumentTypeEnum.kPartDocumentObject
            Dim part As PartDocument = ThisDoc.Document
            ThickenPart(part, 0.1)
    End Select

End Sub

Sub ThickenAssembly(asm As AssemblyDocument, t As Double)
    For Each doc As Document In asm.AllReferencedDocuments
        If doc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
            Try
                Dim part As PartDocument = doc
                ThickenPart(part, t)
            Catch ex As Exception
                Logger.Debug(ex.Message)
            End Try
        End If
    Next
End Sub

Sub ThickenPart(part As PartDocument, t As Double)
    For Each surfaceBody As SurfaceBody In part.ComponentDefinition.SurfaceBodies
        ThickenSurfaceBody(surfaceBody, t)
    Next
End Sub

Sub ThickenSurfaceBody(surfaceBody As SurfaceBody, t As Double)
    Dim partDef As PartComponentDefinition = surfaceBody.Parent

    'Get all faces of Surface body
    Dim faces As FaceCollection = ThisApplication.TransientObjects.CreateFaceCollection()
    For Each face As Face In surfaceBody.Faces
        faces.Add(face)
    Next

    'Setup ThickenFeatures arguments
    Dim chainFaces As Boolean = True
    Dim createVerticalSurfaces As Boolean = False
    Dim automaticBlanding As Boolean = False

    'Create ThickenFeatures
    partDef.Features.ThickenFeatures.Add(
        faces,
        t,
        PartFeatureExtentDirectionEnum.kPositiveExtentDirection,
        PartFeatureOperationEnum.kJoinOperation,
        chainFaces,
        createVerticalSurfaces,
        automaticBlanding)
End Sub

 

0 Likes