Bim 360有一个很棒的工具叫做#34;比较版本"它允许查看两个Revit模型之间的变化。有关此功能的更多信息,请访问:
此功能是否在Autodesk Forge中找到?我还没有找到它,我确实看到forge有一个BIM 360 API,但我没有看到这个功能。
答案 0 :(得分:2)
您可以使用ForgeAuthor sdk执行此操作。
ForgeAuthor是一个基于.net framework 4.5的.net库,它提供了一种很好的面向对象的方式来操作Audesk Forge Svf模型,就像操作XML或JSON一样简单。
ForgeAuthor可以阅读Autodesk Forge SVF模型,比较差异并生成差异模型。
#region setup materials
var matUnmodified = new Material
{
Color = Vector3D.FromColor(0xffffff), //Darker: Vector3D.FromColor(0x101010)
Transparent = 0.95,
Reflectivity = 0
};
var matAdd = new Material
{
Color = Vector3D.FromColor(Color.GreenYellow)
};
var matDelete = new Material
{
Color = Vector3D.FromColor(Color.Red)
};
var matModifiedBefore = new Material
{
Color = Vector3D.FromColor(Color.Orange),
Transparent = 0.5
};
var matModifiedAfter = new Material
{
Color = Vector3D.FromColor(Color.Aqua),
};
#endregion
var baseModelPath = txtBaseModel.Text;
var incrModelPath = txtIncrementModel.Text;
var diffModelPath = txtDiffModel.Text;
var svfbase = baseModelPath.EndsWith(@"zip")
? SvfDocument.LoadFromZipFile(baseModelPath)
: SvfDocument.LoadFromSvfFile(baseModelPath);
var svfincr = incrModelPath.EndsWith(@"zip")
? SvfDocument.LoadFromZipFile(incrModelPath)
: SvfDocument.LoadFromSvfFile(incrModelPath);
var compareResult = CompareModel(svfbase, svfincr);
var svfdiff = new SvfDocument();
svfdiff.Model.Name = @"Diff Model";
svfdiff.Metadata = svfbase.Metadata;
var nodeUnmodified = svfdiff.Model.Children.CreateNode();
nodeUnmodified.Name = @"Unmodified";
var nodeAdded = svfdiff.Model.Children.CreateNode();
nodeAdded.Name = @"Added";
var nodeDeleted = svfdiff.Model.Children.CreateNode();
nodeDeleted.Name = @"Deleted";
var nodeModifiedBefore = svfdiff.Model.Children.CreateNode();
nodeModifiedBefore.Name = @"Modified Before";
var nodeModifiedAfter = svfdiff.Model.Children.CreateNode();
nodeModifiedAfter.Name = @"Modified After";
svfbase.EnumerateNodes(node =>
{
if (node.Children?.Count == 0 &&
node.Fragments?.Count > 0 &&
string.IsNullOrEmpty(node.ExternalId) == false)
{
if (compareResult.Unmodified.Remove(node.ExternalId))
{
ImportNodeWithPath(nodeUnmodified, node, svfbase.Model, matUnmodified);
}
else if (compareResult.Deleted.Remove(node.ExternalId))
{
ImportNodeWithPath(nodeDeleted, node, svfbase.Model, matDelete);
}
else if (compareResult.Modified.Contains(node.ExternalId))
{
var targetNode =
ImportNodeWithPath(nodeModifiedBefore, node, svfbase.Model, matModifiedBefore);
targetNode.ExternalId += @"_Before";
}
}
}, svfbase.Model);
svfincr.EnumerateNodes(node =>
{
if (node.Children?.Count == 0 &&
node.Fragments?.Count > 0 &&
string.IsNullOrEmpty(node.ExternalId) == false)
{
if (compareResult.Added.Remove(node.ExternalId))
{
ImportNodeWithPath(nodeAdded, node, svfincr.Model, matAdd);
}
else if (compareResult.Modified.Remove(node.ExternalId))
{
ImportNodeWithPath(nodeModifiedAfter, node, svfincr.Model, matModifiedAfter);
}
}
}, svfincr.Model);
svfdiff.SaveToFolder(diffModelPath, true);
svfdiff.Dispose();
svfbase.Dispose();
svfincr.Dispose();
private (HashSet<string> Unmodified, HashSet<string> Added, HashSet<string> Deleted, HashSet<string> Modified)
CompareModel(SvfDocument svfbase, SvfDocument svfincr)
{
var baseNodes = new Dictionary<string, SvfNode>();
svfbase.EnumerateNodes(node =>
{
if (node.Children?.Count == 0
&& node.Fragments?.Count > 0
&& string.IsNullOrEmpty(node.ExternalId) == false)
{
baseNodes[node.ExternalId] = node;
}
}, svfbase.Model);
var elementsAdded = new HashSet<string>();
var elementsUnmodified = new HashSet<string>();
var elementsModified = new HashSet<string>();
var elementsDeleted = new HashSet<string>();
svfincr.EnumerateNodes(node =>
{
if (node.Children?.Count == 0
&& node.Fragments?.Count > 0
&& string.IsNullOrEmpty(node.ExternalId) == false)
{
if (baseNodes.TryGetValue(node.ExternalId, out SvfNode baseNode))
{
if (baseNode.Fragments.Equals(node.Fragments))
{
elementsUnmodified.Add(node.ExternalId); //unmdified
}
else
{
elementsModified.Add(node.ExternalId); //modified
}
baseNodes.Remove(node.ExternalId);
}
else
{
elementsAdded.Add(node.ExternalId); //added
}
}
}, svfincr.Model);
foreach (var p in baseNodes.Keys)
{
elementsDeleted.Add(p); //deleted
}
baseNodes.Clear();
return (elementsUnmodified, elementsAdded, elementsDeleted, elementsModified);
}
private SvfNode ImportNodeWithPath(SvfNode targetNodeRoot, SvfNode sourceNode, SvfNode sourceNodeRoot, Material material)
{
var targetNode = sourceNode.Parent == sourceNodeRoot
? targetNodeRoot
: ImportNodeWithPath(targetNodeRoot, sourceNode.Parent, sourceNodeRoot, material);
var resultNode = targetNode.Children.FirstOrDefault(x => x.Name == sourceNode.Name);
if (resultNode == null)
{
resultNode = targetNode.Children.ImportNode(sourceNode, null, false);
foreach (var fragment in resultNode.Fragments)
{
fragment.Material = material;
}
}
return resultNode;
}
答案 1 :(得分:1)
不,至少现在。会很好,不是吗?也许将来......