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.
- posted
16 years ago
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.
The API help makes more sense if you are literate in C or VBA.
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)
generated plane, not on it.
THanks
If you want to do anything useful with macros, you need to learn VBA and understand object-oriented programming. Recording barely gets you started.
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.