平台最多可打开8个视窗,每个视窗可以显示不同的model。平台提供了平铺视图、单视口显示、两视口显示、三视口显示、多视口平铺等功能。平台实现多视图的代码如下。
[BPExternalCommandAttribute(name = "multiView")]
public class MultipleviewportDemo : IBPFunctionCommand
{
public override void onExcute(BPCommandContext context)
{
BPModelId modelId1 = new BPModelId();
string strModel1 = "Modell";
BPStatus bre1 = BPApplication.singleton().activeDocument.modelManager.createNewModel(modelId1, strModel1,BPModelType.enPhysical);
if (bre1 == BPStatus.enERROR)
return;
BPModelId modelId2 = new BPModelId();
string strModel2 = "Mode12";
BPStatus bre2 = BPApplication.singleton().activeDocument.modelManager.createNewModel(modelId2, strModel2,BPModelType.enPhysical);
if (bre2 == BPStatus.enERROR)
return;
BPApplication.singleton().activeDocument.viewManager.displayModelOnViewPort(modelId1,0);
BPApplication.singleton().activeDocument.viewManager.displayModelOnViewPort(modelId2,1);
base.onExcute(context);
}
}
代码5-2 多视图创建
代码中,预先创建了两个视图,视图的index分别是0和1,在这两个视图中分别放置了两个model,这个可以实现不同的model在不同的view中显示,在我们需要二三维多视图显示对照查看时,就可采用这种方式进行创建。