Util.ErrorMsg

Util.ErrorMsg

Anonymous
Not applicable
1,144 Views
4 Replies
Message 1 of 5

Util.ErrorMsg

Anonymous
Not applicable

Hello,

I got the following code from

http://thebuildingcoder.typepad.com/blog/2013/06/family-api-add-in-load-family-and-place-instances.h...

 

  if( null == family )
  {
    // It is not present, so check for 
    // the file to load it from:
 
    if( !File.Exists( FamilyPath ) )
    {
      Util.ErrorMsg( string.Format(
        "Please ensure that the sample table "
        + "family file '{0}' exists in '{1}'.",
        FamilyName, _family_folder ) );
 
      return Result.Failed;
    }
 
    // Load family from file:
 
    using( Transaction tx = new Transaction( doc ) )
    {
      tx.Start( "Load Family" );
      doc.LoadFamily( FamilyPath, out family );
      tx.Commit();
    }
  }

 SharpDevelop in Revit gives an error when building that it does not know Util.
Should I load a class for this? See the screen shot

 

Thank you,

Hadi

Capture.PNG

0 Likes
Accepted solutions (1)
1,145 Views
4 Replies
Replies (4)
Message 2 of 5

dante.van.wettum
Advocate
Advocate

You forgot part of the sample code. check the Util.cs as well.

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/U...

 

here you have the method:

 public static void ErrorMsg( string msg )
    {
      Debug.WriteLine( msg );
      WinForms.MessageBox.Show( msg,
        _caption,
        WinForms.MessageBoxButtons.OK,
        WinForms.MessageBoxIcon.Error );
    }

So you can either  implement the Utils class or just change it in your code to something like TaskDialog.show();

Message 3 of 5

Anonymous
Not applicable

Hi.
Thank you for the reply.
I would like to use Util.cs form below so that I can use its other features.

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/U...

 

Apparently, I do not know how to use an external class in my code. I made a new class and copied the code but when I tried to build it seems that it is not introduced.
I am still a beginner in using external classes.

I would be grateful if you could guide me on this.

0 Likes
Message 4 of 5

jeremytammik
Autodesk
Autodesk
Accepted solution

Change the namespace to be the same.

 

Read about .NET namespaces before doing anything else:

 

https://www.tutorialspoint.com/csharp/csharp_namespaces.htm

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 5

Anonymous
Not applicable

Thank you & I will.

 

 

0 Likes