老师好,cell 已经创建完成,首先感谢您的提携和教导,总算代码完成了cell的创建任务,但是与系统中自带的cell库中的cell 相比较,发现没有图片中标红的部分,缺少这个属性。
另外,通过代码mdlCell_placeCell 调用系统的cell后,发现这种调用方式也没有看见右键菜单 中有 edit item 这个菜单。
问题整理如下 烦请耐心 看一下:
1、直接使用平台上cell库中的cell,右键属性中有一个 EditItem 可以对cell进行参数调整或修改的功能,但是代码创建的没有该功能,请问如果代码创建的画需要这个Edit Item 功能点,应该怎么解决?
2、代码(mdlCell_placeCell)调用系统内置的cell库中的cell后,发现也没有Edit Item 该功能。请问应该怎么调整调用方式?
出不出现这个Edit Item与Cell无关,而与你这个元素(普通图形元素或Cell皆可)是否关联了Item有关。ItemType是非图形属性的定义,Item就是按照某个ItemType关联到图形元素上的具体非图形属性。
请选择MSCE的Riibon菜单Attach > Item Types学习使用ItemType。
付老师,您好!
情况是这样的,您说的那个 自己定义cell文件 创建cell,然后给cell添加item type 我们已经添加了。另外我们测试的cell 是系统内置的情况如下:
用代码(mdlCell_placeCell)调用的时候,发现没有Edit Item 该功能,但是如果从应用库中直接直接拖拽出来,使用测试的时候 是有Edit Item 选项的,所以个人判断是自己在调用的时候 出现的问题。调用的语句为:
mdlCell_placeCell (&pts[1], &bili, true, &jiaodu,NULL, 0, false,0,0,cellname1, NULL);
您看一下 是u是调用的时候 有问题?
另外我们已经使用代码创建了cell,想知道有没有类似于添加item type 选项的API 提供?
另外我在绘制线性结构的时候,使用的都是默认的实线,如果需要调整线性 比如虚线 是否有API可以参考?
Bentley 二次开发小白一枚
老师您好, 我看了一下您的代码,学习了一下,但是感觉您是将点单元 或 图形单元 (非参数化单元)转化成参数化单元,对吗?
那么转成参数单元后,不使用mdlCell_placeCell 放置 的话 ,要用 什么API放置呢?
老师好,您的代码我已经看过了 ,我理解是 将非参数化cell转化成 参数化cell的功能 对吗?但是我的问题是 使用代码放置cell在设计文件上,然后希望能通过右键单击cell 有edit item 选项。
您上面提到mdlCell_placeCell 不能放置参数化单元,那么应该用什么办法呢?还是 我对您上面提供的代码 理解有问题呢?也就是说您上面的代码有和mdlCell_placeCell (放置)类似的功能呢?
整个代码就是在演示如何根据一个参数化单元的名字放置一个参数化单元呀。核心的几行代码如下:
ParametricCellDefinitionPtr pcDef = defHandler.GetCellDefinition(ElementHandle(pcDefRef));
ParameterStatus status; ParametricCellInfoPtr pcInfo = ParametricCellInfo::Create(status, *pcDef, setName, *pDgnModel);
ParametricCellHandler& pcHandler = ParametricCellHandler::GetInstance(); EditElementHandle eeh; if (ParameterStatus::Success != pcHandler.CreateCellElement(eeh, *pcInfo)) return; eeh.AddToModel();
/*-------------------------------------------------------- | createParametricCell | pcName --> (ParametricCellDefHandler)--> ParametricCellDefinition + (setName)--> ParametricCellInfo (ParametricCellHandler)--> EditElementHandle | ParameterSetCollection / ParameterSet | ParameterDefinition / EditParameterDefinitions | DgnComponentDefinitionHandler, DgnComponentDefinitionModelHandler +-------------------------------------------------------*/ DgnModelPtr LocateCellModel(WCharCP modelName) { WString cellFileName; ConfigurationManager::GetVariable(cellFileName, L"_USTN_WORKSPACESROOT"); cellFileName.AppendA("Example\\WorkSets\\MetroStation\\Standards\\Cell\\MetroStation.cel"); if (!BeFileName::DoesPathExist(cellFileName.GetWCharCP())) { mdlDialog_dmsgsPrint(L"Can't find MetroStation.cel"); return nullptr; } DgnDocumentPtr pDgnDoc = DgnDocument::CreateForLocalFile(cellFileName.GetWCharCP()); DgnFilePtr pDgn = DgnFile::Create(*pDgnDoc, DgnFileOpenMode::ReadOnly); StatusInt openForWriteStatus; pDgn->LoadDgnFile(&openForWriteStatus); pDgn->FillDictionaryModel(); DgnModelPtr pModel = pDgn->LoadModelById(pDgn->FindModelIdByName(modelName)); pDgn->FillSectionsInModel(pModel.get()); return pModel; } void createParametricCell(WCharCP unparsed) { WCharCP pcName = L"Double Door Cabinet"; WCharCP setName = L"Standard"; DgnFileP pDgnFile = ISessionMgr::GetActiveDgnFile(); DgnModelP pDgnModel = ISessionMgr::GetActiveDgnModelP(); ParametricCellDefHandler& defHandler = ParametricCellDefHandler::GetInstance(); ElementRefP pcDefRef = defHandler.FindByName(pcName, *pDgnFile); if (pcDefRef == nullptr) { DgnModelPtr pcDefModel = LocateCellModel(pcName); if (pcDefModel.IsNull() || !pcDefModel.IsValid()) { mdlDialog_dmsgsPrint(L"Can't find parametric cell definition"); return; } IDgnComponentDefinitionHandlerP pCompDefHandler = pcDefModel->GetDgnComponentDefinitionHandler(); IDgnComponentDefinitionModelHandlerCP pCompDefModelHandler = pCompDefHandler->GetDefinitionModelHandler(); ParameterStatus status = pCompDefModelHandler->CreateCellDefinition(*pDgnFile); if (ParameterStatus::Success == status) pcDefRef = defHandler.FindByName(pcName, *pDgnFile); else { mdlDialog_dmsgsPrint(L"Error Creating ParametricCell Definition"); return; } } ParametricCellDefinitionPtr pcDef = defHandler.GetCellDefinition(ElementHandle(pcDefRef)); ParameterStatus status; ParametricCellInfoPtr pcInfo = ParametricCellInfo::Create(status, *pcDef, setName, *pDgnModel); ParametricCellHandler& pcHandler = ParametricCellHandler::GetInstance(); EditElementHandle eeh; if (ParameterStatus::Success != pcHandler.CreateCellElement(eeh, *pcInfo)) return; eeh.AddToModel(); }
傅老师:
您好,您的这段代码 我已经看过了,但是有个问题 想咨询一下。如下:
1、当我自己 创建cel文件后,放在我指定的位置后,比如E:\\ 盘下的时候,我通过mdlCell_attachLibrary 加载该 cel文件,是可以成功的,但是发现 pcDefRef == nullptr ,所以 需要调用 LocateCellModel 函数,而在 该函数中您 是 使用了 ConfigurationManager::GetVariable(cellFileName, L"_USTN_WORKSPACESROOT"); 那 这部分的功能是什么呢?
2、我现在的问题是,MicroStation 中 如果没有打开过 我自己设计的 cel 文件, 就会报Can't find parametric cell definition 的错误。所以我想问的是 ,这是一个什么原因造成的?另外需要怎么 样 解决这个问题?
为了方便您的查看,我把您的代码 已经 复制过来了 !
所以 辛苦老师 帮忙 分析一下,并告知原因 !!!!谢谢老师 !!!!!!
问题已经解决, 不要在 系统环境内 查找 ,在自己定义的 目录内查找就可以了!!!!
Answer Verified By: 平凡人生