Greg Marz


Discussion created by Greg Marz on Aug 18, 2020

Hi all,


  I am in need of some help from one of you macro experts. I am trying to write a macro that will let me 1st select a sketch point in a drawing view. Then run a macro that will keep the point I selected and then select all the visible edges in the view that I picked the point in. Then I can use my Ordinate dimension macros to dimension the view. Currently the selection macro I run will pick all the edges in any view I have selected. I will then use my dimension macros to add the dimesions. The down side is Solidworks picks the 1st item selected as the zero when making the dimension. Then I move the zero to where I need it. The problem with that is if solidworks picks an odd edge that it then can not make the 1st dimension the macro will stop.


Here is my selection macro

Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSelMgr As SldWorks.SelectionMgr
Dim swComp As SldWorks.Component2
Dim swView As SldWorks.View
Dim swEnt As SldWorks.Entity
Dim vComps As Variant
Dim vEdges As Variant
Dim i As Integer
Dim j As Integer
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swModelDocExt = swModel.Extension
    Set swSelMgr = swModel.SelectionManager
    Set swView = swSelMgr.GetSelectedObject6(1, -1)
    swModel.ClearSelection2 True
    'Get all visible components
    vComps = swView.GetVisibleComponents
    For i = 0 To UBound(vComps)
        'Get all edges on the first visible component
        vEdges = swView.GetVisibleEntities(vComps(i), swViewEntityType_Edge)
        'Iterate through and select all edges on the first visible component
        For j = 0 To UBound(vEdges)
            Set swEnt = vEdges(j)
            swView.SelectEntity swEnt, True
        Next j
    Next i
End Sub


I want to add sometyhing like this


boolstatus = Part.ActivateView("")
    boolstatus = Part.Extension.SelectByID2("", "DRAWINGVIEW", 0.198194976357053, 0.659088705638048, 0, False, 0, Nothing, 0)
    boolstatus = Part.Extension.SelectByID2("", "EXTSKETCHPOINT", 0, 0, 0, False, 0, Nothing, 0)



any help would be great