日期:2014-01-27  浏览次数:20435 次

Solidworks二次开发—07—控制草图对象

Get All Elements of Sketch Example (VB)




Solidwork中对草图的控制,下面的例子很详细。特征下的草图在solidwork中其实是特征的子特征,我们可以对特征进行GetFirstSubFeature、及GetNextSubFeature得到。



如果有需要大家可以从中找到对直线、弧线、圆等对象的操作。代码是solidworks的示例文件,里面充斥了debug.print,只是向用户显示程序执行的结果。



 

This example shows how to get all of the elements of a sketch.



 



'---------------------------------------------



' Preconditions: Model document is open and a sketch is selected.



' Postconditions: None



'---------------------------------------------



 



Option Explicit



Public Enum swSkSegments_e



    swSketchLINE = 0



    swSketchARC = 1



    swSketchELLIPSE = 2



    swSketchSPLINE = 3



    swSketchTEXT = 4



    swSketchPARABOLA = 5



End Enum



Sub ProcessTextFormat _



( _



    swApp As SldWorks.SldWorks, _



    swModel As SldWorks.ModelDoc2, _



    swTextFormat As SldWorks.textFormat _



)



    Debug.Print "        BackWards                    = " & swTextFormat.BackWards



    Debug.Print "        Bold                         = " & swTextFormat.Bold



    Debug.Print "        CharHeight                   = " & swTextFormat.CharHeight



    Debug.Print "        CharHeightInPts              = " & swTextFormat.CharHeightInPts



    Debug.Print "        CharSpacingFactor            = " & swTextFormat.CharSpacingFactor



    Debug.Print "        Escapement                   = " & swTextFormat.Escapement



    Debug.Print "        IsHeightSpecifiedInPts       = " & swTextFormat.IsHeightSpecifiedInPts



    Debug.Print "        Italic                       = " & swTextFormat.Italic



    Debug.Print "        LineLength                   = " & swTextFormat.LineLength



    Debug.Print "        LineSpacing