Get referenced entityname of sketch entity API

Discussion in 'SolidWorks' started by jjzwaard, Jul 19, 2005.

  1. jjzwaard

    jjzwaard Guest

    LS,

    I'm working on a macro that selects sketchsegments based on the name of
    the referenced entity (all segments are converted from a 3d model into
    a 2d drawing). But I just can't get the relations properly. Can anyone
    help??

    Thanx

    I'm using this code:

    Dim swApp As SldWorks.SldWorks
    Dim model As SldWorks.ModelDoc2
    Dim swsketch As SldWorks.sketch
    Dim swsketchseg As SldWorks.SketchSegment
    Dim swsketch_relman As SldWorks.SketchRelationManager
    Dim swsketch_rel As SldWorks.SketchRelation
    Dim draw As SldWorks.DrawingDoc

    Dim boolstatus As Boolean
    Dim longstatus As Long, longwarnings As Long
    Dim FeatureData As Object
    Dim Feature As Object
    Dim Component As Object

    Sub main()

    Set swApp = Application.SldWorks
    Set model = swApp.ActiveDoc

    Set swsketch = model.GetActiveSketch2

    If Not swsketch Is Nothing Then

    Set swsketch_relman = swsketch.RelationManager

    vswsketchseg = swsketch.GetSketchSegments

    For sketchsegcount_drw = 0 To UBound(vswsketchseg)
    Set swsketchseg = vswsketchseg(sketchsegcount_drw)

    swsketchseg.Select (True)
    swsketchseg_relcount = swsketchseg.GetRelationsCount
    swsketchrels = swsketchseg.GetRelations
    Set swsketch_rel = swsketchrels

    DefEnt_arr = swsketch_rel.GetDefinitionEntities

    Next sketchsegcount_drw
    End If
    End Sub
     
    jjzwaard, Jul 19, 2005
    #1
  2. jjzwaard

    That70sTick Guest

    Could your describe your goal in a little more detail?
     
    That70sTick, Jul 19, 2005
    #2
  3. jjzwaard

    jjzwaard Guest

    Lines from a sketch in a 3d model have to be converted in the 2d
    drawing. A prefix in the sketchname determines the linetype that has to
    be used. After converting the line in the 2d drawing, SW automatically
    clears the selection, which means that I have to get the entity again.
    The easiest way to do this is by first converting all sketch entities
    (from different sketches) from the sketch in the 3d model to the 2d
    drawing and afterwards select all sketchsegments that have an external
    reference to a sketch with a certain prefix.

    Basicly I want to select all sketchsegments that have a relation to the
    same sketch.

    I already have got a solution , but that's taking more time and more
    programming. This would be the easiest and more reliable.
     
    jjzwaard, Jul 19, 2005
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.