has anyone seen a macro that will do this?

I find myself needing to constrain lines and arc centerpoints as
coincident quite a lot of the time. Kind of a line/arc perpendicular
constraint rather than tangent. Currently I select the line and the arc
section ( thus highlighting the arc centerpoint ), zoom as necessary to
see/select the centerpoint, de-select the arc, then constrain the line and
centerpoint coincident. This can be a true pain especially when arc radii
are large or there are a lot of arcs to deal with.
I have tried a couple of times to create a macro that will allow me to
pre-select the line and arc, switch selection from the arc to its
centerpoint, and add the constraint. I haven't had any luck getting the
selection to switch focus. If anyone has a suggestion, or better yet,
recalls where they may have seen a macro that performs the same funtion, any
assistance would be appreciated.
Reply to
Loading thread data ...
Is there something wrong with using the tangent arc tool to do this? Just drag the tangent arc perpendicular instead of tangent to the line and it will give you a perp arc.
Of course you could still get a macro, if you want.
Reply to
Reply to
I think I found a solution to what you need if I understand your needs correctly. Before you draw the line that you want to intersect the arc center, right click on the arc and turn on curve combs. Then start your line off and move the second end until the arc combs highlight (approximately normal to the curve). If you place the second end of the line while the combs are highlighted, an automatic coincident relation is created between the line and the arc center. This will do what you want without the necessity finding the arc center. That is, .
Reply to
That is exactly the kind of relationship I was looking to add. Hadn't thought of using curvature combs. It helps to differentiate as to which object its trying to snap. I tend not to use automatic relationships due to some accidental relationships that were created in the past, but here.... it will deffinately save some time, thanks.
I also did not know the tangent arc tool could be used to somewhat similar effect, thanks for the tip Matt.
Reply to
Here's a macro that will expect 3 things to be preselected, then it will Coincident Relate the 1st and 3rd things. Enjoy, Ken
'*************************** ' CoincidentRelate1stAnd3rdSketchSelections.swp '***************************
Option Explicit Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swSelMgr As SldWorks.SelectionMgr Dim swSelData As SldWorks.SelectData Dim EntityArray(3) As Object
Sub main()
Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc
'Set up Selection Manager Set swSelMgr = swModel.SelectionManager Set swSelData = swSelMgr.CreateSelectData
'Write Pre-Selections to an Array Set EntityArray(1) = swSelMgr.GetSelectedObject5(1) Set EntityArray(2) = swSelMgr.GetSelectedObject5(2) Set EntityArray(3) = swSelMgr.GetSelectedObject5(3)
swModel.ClearSelection2 True
'Select only the 1st and 3rd pre-selected entities EntityArray(1).Select4 True, swSelData EntityArray(3).Select4 True, swSelData
'Add Coincident Mate swModel.SketchAddConstraints "sgCOINCIDENT"
swModel.ClearSelection2 True End Sub
Reply to
Tin Man
Another thing you could do to make it easier to select the point is to use the Selection Filter. To take that a step further, below is a macro to turn on the Selection Filter with only Sketch Point filtering active.
' ****************************************************************************** ' SelectionFilterPointsOnly.swp ' ******************************************************************************
Option Explicit Dim swApp As Object Dim swModel As Object Dim boolstatus As Boolean Dim longstatus As Long, longwarnings As Long Dim FeatureData As Object Dim Feature As Object Dim Component As Object Dim RetVal As Variant Dim iCount As Integer
Sub main()
Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc
'Activate filtering swApp.SetApplySelectionFilter True
'Get list of curently turned on filters RetVal = swApp.GetSelectionFilters
'Turn off the below filters For iCount = 0 To UBound(RetVal) swApp.SetSelectionFilter RetVal(iCount), False Next iCount
'Turn on the below filters swApp.SetSelectionFilter swSelSKETCHPOINTS, True '=11
End Sub
Reply to
Tin Man

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.