Reference another CS file

Reference another CS file

Anonymous
Not applicable
468 Views
2 Replies
Message 1 of 3

Reference another CS file

Anonymous
Not applicable

Can someone tell me how to reference a function in another separate CS file, within the same project? I made  CreateForm() function public, but I am clearly missing something in the way I am trying to reference it.

 

namespace createViewsAndSheets
{
	public class createForm
	{
             public void CreateForm()
             {
.......

 

I am trying to use this to reference the function within the separate createForm.CS file. What am I doing wrong?

 

// Create form
createViewsAndSheets.createForm.CreateForm();
0 Likes
469 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

...I think I may have answered my own question. It appears that the CreateForm() function needed to be defined as "static" to reference it. This seemed to fix it, but can someone tell me why this is?

0 Likes
Message 3 of 3

cwaluga
Advocate
Advocate

Class vs. instance. Basically the same explanation as to why you cannot edit instance parameters in a type in Revit. This is basic C# and thus not suitable for this forum if no Revit API is involved in the question. No offense, but: Learn the language before you develop Revit addins, seriously!