Hi,
Welcome to this forum.
What you are trying to do is implementing 'Standard Revit API' code (created with Microsoft Visual Studio) to 'Revit Macro API' environment (create macro in Sharpdevelop editor).
That definitely won't work.
There are some differences between these API you should be aware of, otherwise all code (snippets) on this forum make no sense to you how to migrate the code to your Revit macro IDE.
I have found some useful links you might be interested;
general use of the macro manager and the Revit Macro IDE
https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/CloudHelp/cloudhelp/2019/EN...
Revit API differences reference
http://help.autodesk.com/view/RVT/2019/ENU/?guid=GUID-C6E0196D-918B-4131-9B64-050DBE452158
example code from standard Revit API to Revit macro IDE
http://help.autodesk.com/view/RVT/2019/ENU/?guid=GUID-8870CDF7-A248-4423-9CB6-D2E2C62FC3DB
To give you an idea how this code could look like as a macro see inserted code
(i have also included the using directive 'Autodesk.Revit.DB.Structure;')
Copy and paste the code in your macro IDE, build solution and there should be no error displaying.
I hope this is useful for you and wish you good luck with your journey here with the Revit API.
Cheers,
So-Chong
using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.DB.Structure;
using System.Collections.Generic;
using System.Linq;
namespace SetRebarSolid
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.DB.Macros.AddInId("69497BD4-FEC5-4FF7-87B7-D5696A5B0C5D")]
public partial class ThisApplication
{
private void Module_Startup(object sender, EventArgs e)
{
}
private void Module_Shutdown(object sender, EventArgs e)
{
}
#region Revit Macros generated code
private void InternalStartup()
{
this.Startup += new System.EventHandler(Module_Startup);
this.Shutdown += new System.EventHandler(Module_Shutdown);
}
#endregion
public void SetSolidRebar()
{
Document doc = this.ActiveUIDocument.Document;
ICollection<Element> rebars = new FilteredElementCollector(doc, doc.ActiveView.Id).OfCategory(BuiltInCategory.OST_Rebar).ToElements();
List<Rebar> List_Rebar = new List<Rebar>();
if(rebars==null)
{
TaskDialog.Show("REBAR", "NO REBAR EXISTS IN THE DRAWINGS");
}
using (Transaction trans = new Transaction(doc, "Set Solid Rebar"))
{
trans.Start();
IEnumerable<ViewFamilyType> VFT = from Element in new FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType)) let type = Element as ViewFamilyType where type.ViewFamily == ViewFamily.ThreeDimensional select type;
View3D v3d = doc.ActiveView as View3D;
foreach(Rebar r in rebars)
{
r.SetSolidInView(v3d, true);
List_Rebar.Add(r);
}
TaskDialog.Show("LIST_REBAR", List_Rebar.Count().ToString());
trans.Commit();
}
}
}
}