Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.ApplicationServices;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System;
namespace NewJeans
{
[Transaction(TransactionMode.Manual)]
public class ExtractSharedParamsGUID : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
Application app = commandData.Application.Application;
List<string> result = new List<string>();
var familyInstances = new FilteredElementCollector(doc)
.OfClass(typeof(FamilyInstance))
.Cast<FamilyInstance>()
.ToList();
List<Family> families = familyInstances
.Select(fi => fi.Symbol.Family)
.Distinct().ToList();
foreach (Family fam in families)
{
Document famDoc = doc.EditFamily(fam);
FamilyManager fm = famDoc.FamilyManager;
using (Transaction trans = new Transaction(famDoc, "ExtractFamilyParameter"))
{
trans.Start();
foreach (FamilyParameter p in fm.Parameters)
{
string name = p.Definition.Name;
string defType = p.Definition.GetType().Name;
if (p.IsShared)
{
if (p.Definition is ExternalDefinition extDef)
{
string guid = extDef.GUID.ToString();
result.Add($" {fam.Name} - {name} : Shared, GUID: {guid}");
}
else if ((p.Definition is InternalDefinition intDef))
{
string type = intDef.ToString();
result.Add($" {fam.Name} - {name} : Shared, but {type}");
}
}
else
{
result.Add($" {fam.Name} - {name} : Not Shared");
}
}
trans.RollBack();
}
famDoc.Close(false);
}
TaskDialog.Show("Shared Parameters", string.Join("\n", result));
return Result.Succeeded;
}
}
}
this is the code and result is
I correctly added the Shared Parameter to the family("shared2", "shared@").
When I access the parameter in the API, it shows up as InternalDefinition, even though the IsShared property returns True.
Has anyone encountered this issue before? What am I missing? How can I ensure that the Shared Parameter is recognized properly as a Shared Parameter in the API, rather than an InternalDefinition? please.... Help me
Solved! Go to Solution.