Defining a plane in a VB script from 3 points

Discussion in 'SolidWorks' started by Ben, Oct 27, 2007.

  1. Ben

    Ben Guest

    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.
     
    Ben, Oct 27, 2007
    #1
  2. Ben

    That70sTick Guest

    The API help makes more sense if you are literate in C or VBA.
     
    That70sTick, Oct 27, 2007
    #2
  3. Ben

    That70sTick Guest

    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
     
    That70sTick, Oct 27, 2007
    #3
  4. Ben

    Ben Guest

    Great thanks
     
    Ben, Oct 28, 2007
    #4
  5. Ben

    Ben Guest

    OK, so now on my new plane, in a macro, how can i generate a set of
    concentric circles with radii 12,10 (mm)
    generated plane, not on it.

    THanks
     
    Ben, Oct 28, 2007
    #5
  6. Ben

    That70sTick Guest

    If you want to do anything useful with macros, you need to learn VBA
    and understand object-oriented programming. Recording barely gets you
    started.
     
    That70sTick, Oct 28, 2007
    #6
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.