필드 작성기가 생성 된 코드 행은 문자열, int, XYZ 등으로 저장할 수있는 유형을 할당합니다.builtInCategory 유형을 사용할 수없는 경우 Revit Built-In Category 목록을 작성하는 방법
개발자 설명서에 "BuiltInCategory"유형이 없습니다. 이 List<BuiltInCategory>
을 "projectinfo 객체"에 저장하여 저장해야합니다. List<BuiltinCategory>
을 저장 용 문자열 List<string>
에 캐스트 한 다음 검색을 위해 다시 변환해야합니까? 그게 효과가 있니?
public void StoreDataInProjectInfo(Document doc, Element projectInfoElement)
{
Schema schema = Schema.Lookup(SchemaGuid);
IList<BuiltInCategory> BuiltincatStringList = new List<BuiltInCategory>();
BuiltincatStringList.Add("1");
BuiltincatStringList.Add("2");
using (Transaction transEstorage = new Transaction(doc))
{
transEstorage.Start("add estorage list");
if (null == schema)
{
SchemaBuilder sb = new SchemaBuilder(new Guid("AF5E4C3E-C2E2-493B-8236-BA0F5E323887"));
//public accesibility
sb.SetReadAccessLevel(AccessLevel.Public);
sb.SetWriteAccessLevel(AccessLevel.Public);
이것은 실행시 코드가 실패하고 잘못된 "유형"을보고하는 유형이 필요한 필드 빌더 목록입니다.
//Storage Filled for Cat List
***FieldBuilder fb = sb.AddArrayField("UserCategoryList", typeof(BuiltInCategory))***;
fb.SetDocumentation("A Set Of Categories to be worksetted");
//set schema name and register
sb.SetSchemaName("UserCategoryList");
schema = sb.Finish();
}
// Create an entity (object) for this schema (class)
Entity entity = new Entity(schema);
// Get the field from the schema
Field userWSCategoryList = schema.GetField("UserCategoryList");
entity.Set<IList<BuiltInCategory>>(userWSCategoryList, BuiltincatStringList);
//Entity storage on Element
projectInfoElement.SetEntity(entity);
// Read back the data from the wall
Entity retrievedEntity = projectInfoElement.GetEntity(schema);
IList<BuiltInCategory> retrievedData = retrievedEntity.Get<List<BuiltInCategory>>(schema.GetField("UserCategoryList"));
transEstorage.Commit();
}
}
"ElementId"유형은 스키마 구현시 Revit 개발자 설명서에 따라 사용할 수 있습니다. – Bimtopian
안녕하세요, Ilyst 데이터로 builtincategory를 저장할 수 있지만 이제는 검색된 데이터를 IList <내장 카테고리>로 다시 변환 할 수 없습니다. 이 오류입니다. 'System.Collections.Generic.List '을 'Autodesk.Revit.DB.BuiltInCategory'로 변환 할 수 없습니다. –
Bimtopian