【msce c++】如何把参考文件的元素复制到当前model中?需要保留参考的缩放参数。

我这边可能需求更多一点,我想要的是把参考的图形复制一份保存在 当前model,这些元素需要有参考的旋转,缩放等信息。

如下代码。我做了测试,只是把原始参考文件的元素复制过来了, 这些元素不具有参考的参数,比如旋转和缩放等。

DgnDocumentMonikerPtr moniker = Bentley::DgnPlatform::DgnDocumentMoniker::CreateFromFileName(CCommonOperate::CStringToBentleyWString(frameInfo.sFilePath).c_str(),NULL);

	DgnAttachmentP attachment;
	if (0 != ACTIVEMODEL->CreateDgnAttachment(attachment, *moniker, CCommonOperate::CStringToBentleyWString(frameInfo.sModelName).c_str())) {
		MessageBox::Show("参考模版文件失败");
	}
	attachment->SetStoredScale(dScale);
	attachment->SetMasterOrigin(insertPoint);
	Bentley::DgnModelP dgnModelP = attachment->GetDgnModelP();
	for (PersistentElementRefP const& elemRef : *dgnModelP->GetGraphicElementsP())
	{
		if (CELL_HEADER_ELM != elemRef->GetElementType()) {
			continue;
		}

		Bentley::DgnPlatform::ElementId elmID = elemRef->GetElementId();
		EditElementHandle eehCell(elmID, dgnModelP->AsDgnModelP());
		if (!eehCell.IsValid()) {
			continue;
		}

		Bentley::DgnPlatform::ElementCopyContext copier(ACTIVEMODEL);
		if (SUCCESS != copier.DoCopy(eehCell))
		{
			MessageBox::Show("有一个没成功");
		}
		
	}
	ACTIVEMODEL->DeleteDgnAttachment(attachment);

Parents Reply Children