AnsweredAssumed Answered

How to cerat a part from API

Question asked by ZhongYu Hao on Sep 9, 2018
Latest reply on Sep 10, 2018 by ZhongYu Hao

Hello guys,

I just started learning SW API

And how to creat a New part ,assembly and drawing ,use API.

That is my code,but it is still not work.

---------------------------------------------------------

Imports SolidWorks.Interop.sldworks
Imports System

Public Class Form1
    Private swApp As Object
    Private swDocumentTypes_e As Object
    Private swOpenDocOptions_e As Object

    Sub Main()

        Dim swApp As SolidWorks.Interop.sldworks.SldWorks

        swApp = New SolidWorks.Interop.sldworks.SldWorks()

        swApp.ExitApp()

        swApp = Nothing

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim swModel As ModelDoc2
        Dim swPart As PartDoc
        Dim swBody As Body2
        Dim nPt() As Double
        Dim vPt As Object
        Dim bRet As Boolean

        swModel = swApp.NewDocument("C:\ProgramData\SOLIDWORKS\SOLIDWORKS 2015\templates\part.prtdot", 0, 0, 0)
        swPart = swModel
        swBody = swPart.CreateNewBody

    End Sub

End Class

-------------------------------------------------------------------

Attachments

Outcomes