Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

SW Addin : Sketch Census

Status
Not open for further replies.

diablogato

Industrial
Dec 14, 2012
4
Hello everyone,
Right now, i'm using VB.net 2010 and Solidworks 2011 to make SW VB addin that needs the number of lines used in a part.
I did some research about this problem and found an addin in < called Madmango's sketch census tool and it looks like created into an addin by Thetick. The addin works fine, but i need the code to get the number in a sketch into a variable. I've tried to decompile the .dll file but no results. Maybe someone can help me decompile that file into vb.net or help me with the macro to acquire the number of lines used in a sketch.
Maybe Thetick or Madmango could help me, please?

thanks in advance,
 
Replies continue below

Recommended for you

@Handleman: thanks for the fast response, i haven't tried it yet but i think it will work. i'll write some reports when i've tried it.

@Thetick: it's okay, Handleman got the link to the original thread. All i need is the macro for counting sketch elements. Thanks for your concern.
 
okay, so i've tried this macro from original thread:
Code:
Option Explicit

Public Enum swSkSegments_e
    swSketchLINE = 0
    swSketchARC = 1
    swSketchELLIPSE = 2
    swSketchSPLINE = 3
    swSketchTEXT = 4
    swSketchPARABOLA = 5
End Enum

Dim Total As Integer



Sub main()
    Dim sSkSegmentsName(5)      As String
    
    Dim swApp                   As SldWorks.SldWorks
    Dim swModel                 As SldWorks.ModelDoc2
    Dim swSelMgr                As SldWorks.SelectionMgr
    Dim swFeat                  As SldWorks.feature
    Dim swSketch                As SldWorks.sketch
    Dim vSkSegArr               As Variant
    Dim vSkSeg                  As Variant
    Dim swSkSeg                 As SldWorks.SketchSegment
    Dim swSkLine                As SldWorks.SketchLine
    Dim swSkArc                 As SldWorks.SketchArc
    Dim swSkEllipse             As SldWorks.SketchEllipse
    Dim swSkSpline              As SldWorks.SketchSpline
    Dim swSkText                As SldWorks.SketchText
    Dim swSkParabola            As SldWorks.SketchParabola
    Dim vID                     As Variant
    Dim i                       As Long
    Dim bRet                    As Boolean
    Total = 0
  On Error GoTo huboalgo
    
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
    Set swFeat = swSelMgr.GetSelectedObject4(1)
    Set swSketch = swFeat.GetSpecificFeature
   
    
   [highlight #FCE94F] vSkSegArr = swSketch.GetSketchSegments
    For Each vSkSeg In vSkSegArr
        Set swSkSeg = vSkSeg
        Total = Total + 1
    Next vSkSeg[/highlight]
    MsgBox "Total of segments: " & Total, vbInformation, "SEGMENTS COUNT"
    GoTo THEEND
huboalgo:
    MsgBox "Please select an sketch", vbCritical, "MACRO ERROR"
THEEND:
End Sub

i understand that the highlighted code is the code for counting the segments in a sketch but i wonder how to separate the lines, arcs, and parabolas in different variable.
and i still don't understand the purpose of some variables like swskline, swskarc, swskellpise, and so on.

can somebody help me?
thanks
 
Sorry, your original post kind of made it sound like you knew what you were doing and only needed a nudge in the right direction. Unfortunately, your current level of understanding requires more time to teach than I have. Just writing the code for you would be quicker, but I don't have time for that either. Sorry!

-handleman, CSWP (The new, easy test)
 
okay, thanks for your time.
i'll work my way out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor