×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

API C# STARTING PROBLEM

API C# STARTING PROBLEM

API C# STARTING PROBLEM

(OP)
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
 

RE: API C# STARTING PROBLEM

(OP)
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.

RE: API C# STARTING PROBLEM

(OP)
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'.

RE: API C# STARTING PROBLEM

(OP)
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.





 

RE: API C# STARTING PROBLEM

(OP)
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.
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources