From: Ben on 27 Oct 2007 06:44 Guys I require the syntax to define a plane from 3 points to be executed in a vb macro. The SW API help is horrible, any help would be appreciated.
From: That70sTick on 27 Oct 2007 09:08 The API help makes more sense if you are literate in C or VBA.
From: That70sTick on 27 Oct 2007 09:10 Option Explicit Dim swApp As SldWorks.SldWorks Dim aDoc As SldWorks.ModelDoc2 Dim SelMgr As SldWorks.SelectionMgr Dim NewPlane As SldWorks.RefPlane Sub main() On Error Resume Next Set swApp = Application.SldWorks Set aDoc = swApp.ActiveDoc If aDoc Is Nothing Or (aDoc.GetType <> 1 And aDoc.GetType <> 2) Then MsgBox "Active doc not a part or assembly.": GoTo ExitStrategy 'no active doc or doc not assembly or part Set SelMgr = aDoc.SelectionManager If SelMgr.GetSelectedObjectCount < 3 Then MsgBox "Not enough objects selected to make a plane through 3 points.": GoTo ExitStrategy Set NewPlane = aDoc.CreatePlaneThru3Points3(True) aDoc.EditRebuild3 If NewPlane Is Nothing Then MsgBox "Failed to create plane. Wise up! Be sure you have three points seleted before starting." 'clean up objects before exiting ExitStrategy: Set NewPlane = Nothing Set SelMgr = Nothing Set aDoc = Nothing Set swApp = Nothing End End Sub
From: Ben on 28 Oct 2007 08:09 On Oct 27, 11:10 pm, That70sTick <r...(a)liquidschwarz.com> wrote: > Option Explicit > > Dim swApp As SldWorks.SldWorks > Dim aDoc As SldWorks.ModelDoc2 > Dim SelMgr As SldWorks.SelectionMgr > Dim NewPlane As SldWorks.RefPlane > > Sub main() > On Error Resume Next > > Set swApp = Application.SldWorks > Set aDoc = swApp.ActiveDoc > If aDoc Is Nothing Or (aDoc.GetType <> 1 And aDoc.GetType <> 2) Then > MsgBox "Active doc not a part or assembly.": GoTo ExitStrategy 'no > active doc or doc not assembly or part > Set SelMgr = aDoc.SelectionManager > If SelMgr.GetSelectedObjectCount < 3 Then MsgBox "Not enough objects > selected to make a plane through 3 points.": GoTo ExitStrategy > > Set NewPlane = aDoc.CreatePlaneThru3Points3(True) > aDoc.EditRebuild3 > > If NewPlane Is Nothing Then MsgBox "Failed to create plane. Wise up! > Be sure you have three points seleted before starting." > > 'clean up objects before exiting > ExitStrategy: > Set NewPlane = Nothing > Set SelMgr = Nothing > Set aDoc = Nothing > Set swApp = Nothing > End > End Sub Great thanks
From: Ben on 28 Oct 2007 08:37
On Oct 28, 10:09 pm, Ben <duivest...(a)gmail.com> wrote: > On Oct 27, 11:10 pm, That70sTick <r...(a)liquidschwarz.com> wrote: > > > > > Option Explicit > > > Dim swApp As SldWorks.SldWorks > > Dim aDoc As SldWorks.ModelDoc2 > > Dim SelMgr As SldWorks.SelectionMgr > > Dim NewPlane As SldWorks.RefPlane > > > Sub main() > > On Error Resume Next > > > Set swApp = Application.SldWorks > > Set aDoc = swApp.ActiveDoc > > If aDoc Is Nothing Or (aDoc.GetType <> 1 And aDoc.GetType <> 2) Then > > MsgBox "Active doc not a part or assembly.": GoTo ExitStrategy 'no > > active doc or doc not assembly or part > > Set SelMgr = aDoc.SelectionManager > > If SelMgr.GetSelectedObjectCount < 3 Then MsgBox "Not enough objects > > selected to make a plane through 3 points.": GoTo ExitStrategy > > > Set NewPlane = aDoc.CreatePlaneThru3Points3(True) > > aDoc.EditRebuild3 > > > If NewPlane Is Nothing Then MsgBox "Failed to create plane. Wise up! > > Be sure you have three points seleted before starting." > > > 'clean up objects before exiting > > ExitStrategy: > > Set NewPlane = Nothing > > Set SelMgr = Nothing > > Set aDoc = Nothing > > Set swApp = Nothing > > End > > End Sub > > Great thanks OK, so now on my new plane, in a macro, how can i generate a set of concentric circles with radii 12,10 (mm) >From recording it seems to place the circles I draw behind the generated plane, not on it. THanks |