0

是否可以将单个 CATIA 主体导出为 STL,而无需使用它创建单独的零件?

目前,我编写了一个脚本,该脚本循环遍历文件夹中存在的 CATPart,获取包含的主体并为每个主体创建一个 CATPart,然后导出为 stl 格式。

    Dim output_stl_path_HD As String
    Dim output_stl_path_MD As String
    Dim output_stl_path_SD As String
    Dim output_stl_path_via_points As String
    Dim output_transformations_path As String
    Dim input_path As String

    Sub CATMain()
    'Path for output file


    input_path = CATIA.ActiveDocument.path + "\"


    Dim it As Integer
    Dim prod As Product
    Dim t_p_ref(11)

    'List of part names to export
    Dim list As Collection
    Set list = New Collection


    'GET LIST OF CATPART IN FOLDER
    Dim objFSO As Object
    Dim objFolder As Object
    Dim objFile As Object
    Dim i As Integer

    'Create an instance of the FileSystemObject
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    'Get the folder object
    Set objFolder = objFSO.GetFolder(input_path)
    i = 1
    'loops through each file in the directory and prints their names and path
    For Each objFile In objFolder.Files

        'print file name
        If (InStr(objFile.path, ".CATPart")) Then

            list.Add (objFile.name)

    '        Set objDocument = CATIA.Documents.Open(objFile.path)

            Dim srcDoc As PartDocument
            Set srcDoc = CATIA.Documents.Open(objFile.path)
            Dim srcPart As Part
            Set srcPart = srcDoc.Part

            Dim oSel As Selection
            Dim bodies1 As Bodies
            Dim body1 As body
    '
            Set bodies1 = srcPart.Bodies

            For Each single_body In srcPart.Bodies
                A = exportStl(single_body)
            Next
            Set body1 = srcPart.Bodies.Item(i)

    'Dim BoxProduct
    'BoxProduct = MsgBox("Quantity of the bodies found:" & srcDoc.Part.Bodies.Count & "", 64)

        End If
    Next

    End Sub



    Public Function exportStl(ByVal myBody As body)
        Dim oSrc As Part
        Dim oTgt As Part
        Dim oSrcDoc As PartDocument
        Dim oTgtDoc As PartDocument
        Dim oBod As body
        Dim oSel As Selection

        'Sets documents for Source and Target files
        Set oSrcDoc = CATIA.ActiveDocument
        Set oTgtDoc = CATIA.Documents.Add("Part")
        oTgtDoc.Product.PartNumber = myBody.name




        'Gets Body to copy
        Set oSrc = oSrcDoc.Part
        Set oTgt = oTgtDoc.Part
        Set oBod = myBody
        Set oSel = oSrcDoc.Selection

        'Copies Body
        oSel.Add oBod
        oSel.Copy
        Set oSel = oTgtDoc.Selection

        'Sets and Pastes in Target file as result with link
        oSel.Clear
        oSel.Add oTgt.Bodies.Item(1)
        oSel.Paste
        oSrcDoc.Selection.Clear


         CATIA.ActiveDocument.ExportData input_path + myBody.name, "stl"

         CATIA.ActiveDocument.Close


    End Function
4

1 回答 1

1

Catia V5 能够从零件(CatiaPART 文件)创建 STL 文件,但不能从装配体(CatiaPRODUCT 文件)或几何表示(汽车文件)创建 STL 文件。因此,源文件,包括以中性格式(例如 STEP 或 IGES)保存的源文件,必须保存为部件。如果源设计保存为装配体,它会作为产品导入 Catia。-

资料来源: http: //www.stratasys.com/customer-support/cad-to-stl/catia

我尝试导出CATBody,但没有成功。我们必须有一个 CATPart 来生成 STL

于 2015-12-02T17:48:55.320 回答