• solidworks二次开发学习(1)如何选中一个草图并遍历草图中的所有直线


     1 Imports SolidWorks.Interop.sldworks
     2 Imports SolidWorks.Interop.swconst
     3 Imports System.Runtime.InteropServices
     4 Imports System
     5 
     6 Partial Class SolidWorksMacro
     7 
     8     Public Sub main()
     9 
    10 
    11             Dim swDoc As ModelDoc2 = Nothing
    12             Dim swPart As PartDoc = Nothing
    13             Dim swDrawing As DrawingDoc = Nothing
    14             Dim swAssembly As AssemblyDoc = Nothing
    15             Dim boolstatus As Boolean = false
    16             Dim longstatus As Integer = 0
    17             Dim longwarnings As Integer = 0
    18             swDoc = CType(swApp.ActiveDoc,ModelDoc2)
    19         boolstatus = swDoc.Extension.SelectByID2("AIR_UP_SKETCH", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
    20         swDoc.EditSketch()
    21         swDoc.ClearSelection2(True)
    22 
    23         Dim theSketch As Sketch
    24         theSketch = swDoc.GetActiveSketch2
    25         Dim vSketchSeg As Object
    26         vSketchSeg = theSketch.GetSketchSegments
    27         Dim swSketchSeg As SketchSegment
    28         Dim k = 0
    29         If Not IsNothing(vSketchSeg) Then
    30             For k = 0 To UBound(vSketchSeg)
    31                 swSketchSeg = vSketchSeg(k)
    32                 swSketchSeg.SelectByMark(True, 0)
    33             Next k
    34         End If
    35 
    36 
    37 
    38     End Sub
    39 
    40     ''' <summary>
    41     ''' The SldWorks swApp variable is pre-assigned for you.
    42     ''' </summary>
    43     Public swApp As SldWorks
    44 
    45 
    46 End Class
  • 相关阅读:
    HDU 1849 Rabbit and Grass
    HDU 1848 Fibonacci again and again
    HDU 1847 Good Luck in CET-4 Everybody!
    HDU 1846 Brave Game
    HDU 1387 Team Queue
    HDU 1870 愚人节的礼物
    HDU 1509 Windows Message Queue
    HDU 4381 Grid
    HDU 5800 To My Girlfriend
    HDU 5806 NanoApe Loves Sequence Ⅱ
  • 原文地址:https://www.cnblogs.com/frankwu2014/p/4343652.html
Copyright © 2020-2023  润新知