Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

API C# STARTING PROBLEM

Status
Not open for further replies.

Poldek

Mechanical
Nov 27, 2011
6
Hi

I'm new in SolidWorks API programing.I'm working in C# programing language. I made some programs and this programs work well. But I have a problem with a programs example from SolidWorks API HELP. I copy the program code from HELP and paste it in SolidWorks API editor. When I run this program there are four mistakes:


1. Error 1 'Macro1.csproj.SolidWorksMacro' does not contain a definition for 'swApp'


2.Error 2 The name 'Main' does not exist in the current context


3.Error 3 'Macro1.csproj.SolidWorksMacro' does not contain a definition for 'swApp'


4.Error 4 The name 'Main' does not exist in the current context


Please help me how can I fix this problem
 
Replies continue below

Recommended for you

OK
I solved this problem, but I have the new one.
Please sameone write the short program in C# which it will open the file C:\model.sldprt.
I don't know how can I use OpenDoc6, because the examples for open document from API Help don,t work.
 
Solution of the original problem is very simple. Because I saved the project with name Macro1 and then I delited all code in this program and then paste program code from API help. In code I exchanged the name from API help with 'Macro1'.
 
Please, Can someone convert next short program from VBA to C# :



Option Explicit

Dim swApp As SldWorks.SldWorks
Dim Part As ModelDoc2
Dim Measure As Measure
Dim boolstatus As Boolean

Sub main()

Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set Measure = Part.Extension.CreateMeasure

Debug.Print "Distance: " & Measure.Distance

End Sub





That would be very helpful for me.





 
Yes I can.
But you can't record above program.


This above program get the distance between two selected entities (in VBA).
I don't know how this get in C#. But I realy need this data in C#.

Please help me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor