python二次开发Solidworks:方程式驱动曲线

1、渐开线

import win32com.client as win32
import pythoncom

swApp = win32.Dispatch('sldworks.application')
swApp.Visible = True
Nothing = win32.VARIANT(pythoncom.VT_DISPATCH, None)
swModel = swApp.ActiveDoc
swExt = swModel.Extension
swSelMgr = swModel.SelectionManager
boolstatus = swExt.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
swModel.SketchManager.InsertSketch(True)
swModel.ClearSelection2(True)
rb=0.04698463103929543
skSegment = swModel.SketchManager.CreateEquationSpline2(f"{rb}*cos(t)+{rb}*t*sin(t)", f"{rb}*sin(t)-{rb}*t*cos(t)", "", "0", "pi/4", False, 0, 0, 0, True, True)
swModel.ViewZoomtofit2()

python二次开发Solidworks:方程式驱动曲线_第1张图片

2、正弦曲线

import win32com.client as win32
import pythoncom

swApp = win32.Dispatch('sldworks.application')
swApp.Visible = True
Nothing = win32.VARIANT(pythoncom.VT_DISPATCH, None)
swModel = swApp.ActiveDoc
swExt = swModel.Extension
swSelMgr = swModel.SelectionManager
boolstatus = swExt.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
swModel.SketchManager.InsertSketch(True)
swModel.ClearSelection2(True)
skSegment = swModel.SketchManager.CreateEquationSpline2("", "sin(x)", "", "0", "2*pi", False, 0, 0, 0, True, True)
swModel.ViewZoomtofit2()

python二次开发Solidworks:方程式驱动曲线_第2张图片

你可能感兴趣的:(python,Solidworks)