Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Play Stock Market Games
Fantasy Stock Picking Contest

Computer Aided Design - CAD > Solidworks > Need help with ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 10209 of 10648
Post > Topic >>

Need help with Addin presentation from SW World 2007 - Or Addins

by solidworks311@[EMAIL PROTECTED] May 9, 2008 at 02:22 PM

I'm reviewing a SW World 2007 presentation I attended titled
"SolidWorks Addins Using .NET".

The steps are:

1. Record a simple macro in SolidWorks using VBA.
2. Verify the macro.
3. Start Visual Studio.
4. Create a new SW Addin using SWVBAddin Template.
5. Open SwAddin.vb
6. Expand the code region.
7. Select all of the code in 'Sub CreateCube ()'
8. Use Ctrl+K C to comment out the code
9. Swith back to VBA and select all the code in 'Sub main ()'
10. Copy and paste back to Visual Studio.
11. Add 'Dim' statements for each object.
12. Replace 'Applications.SldWorks' with 'GetObject
(,"SldWorks.Application")'
13. Build the Addin and Run using F5 to debug SolidWorks.

I followed all of the steps, but nothing happens in SolidWorks. The
macro works fine if I run it thru VBA.

Any ideas?   If anyone knows a good tutorial for creating SW Addins
with VB.NET, please post.

Below is the code under 'UI Callbacks'


#Region "UI Callbacks"

Sub main()
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
swApp = GetObject(, "SldWorks.Application")

Part = SwApp.ActiveDoc
SelMgr = Part.SelectionManager
boolstatus = Part.SetUserPreferenceToggle(196, True)
boolstatus = Part.Extension.SelectByID2("Unknown", "BROWSERITEM", 0,
0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Front", "PLANE", 0, 0, 0,
False, 0, Nothing, 0)
Part.SketchManager.InsertSketch(True)
Part.ClearSelection2(True)
Part.SketchRectangle(-0.08407285067873, 0.06711078431373, 0,
0.06953393665158, -0.05404683257919, 0, 1)
Part.SetLineWidth(4)
Part.SetLineWidth(4)
Part.SetLineWidth(4)
Part.SetLineWidth(4)
Part.SetPickMode()
Part.ClearSelection2(True)
Part.SketchManager.InsertSketch(True)
Part.ClearSelection2(True)
End Sub
 




 1 Posts in Topic:
Need help with Addin presentation from SW World 2007 - Or Addins
solidworks311@[EMAIL PROT  2008-05-09 14:22:22 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Aug 7 18:38:57 CDT 2008.