本文整理汇总了C#中CloneContext.ResolveReferences方法的典型用法代码示例。如果您正苦于以下问题:C# CloneContext.ResolveReferences方法的具体用法?C# CloneContext.ResolveReferences怎么用?C# CloneContext.ResolveReferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CloneContext
的用法示例。
在下文中一共展示了CloneContext.ResolveReferences方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportDwgToJpg
public void ExportDwgToJpg(string destPath)
{
string sourcePath = String.Format("{0}{1}.dwg", DefaultDwgFolder, Control.ControlNo);
Dictionary<string, string> dictDim = new Dictionary<string, string>();
foreach (ControlDrawingDetail detail in ControlDrawingDetails)
{
if (dictDim.ContainsKey(detail.Dim.DimNo) == false)
{
dictDim.Add(detail.Dim.DimNo, detail.DimValue);
}
}
try
{
DxfModel readModel = DwgReader.Read(sourcePath);
DxfModel writeModel = new DxfModel();
CloneContext ct = new CloneContext(readModel, ReferenceResolutionType.CloneMissing);
TransformConfig tc = new TransformConfig();
Matrix4D translation = Transformation4D.Translation(250, 0, 0);
ct.RenameClashingBlocks = true;
for (int i = 0; i < readModel.Entities.Count; i++)
{
DxfEntity block = readModel.Entities[i];
if (block.GetType() == typeof(DxfMText))
{
DxfMText di = (DxfMText)block;
if (dictDim.ContainsKey(di.SimplifiedText))
{
di.Text = dictDim[di.SimplifiedText];
di.Width = di.BoxWidth * 2;
}
writeModel.Entities.Add(di);
}
else if (block.GetType() == typeof(DxfText))
{
DxfText di = (DxfText)block;
if (dictDim.ContainsKey(di.SimplifiedText))
{
di.Text = dictDim[di.SimplifiedText];
}
writeModel.Entities.Add(di);
}
else
{
writeModel.Entities.Add(block);
}
}
ct.ResolveReferences();
CADHelper.ExportToJpg(writeModel, destPath);
}
catch (Exception exc)
{
Tracing.Tracer.LogError(exc.Message);
Logger.For(this).Error(exc.Message);
}
}
示例2: puzzle
//.........这里部分代码省略.........
//花标注
DxfDimension.Aligned dxfDimension = new DxfDimension.Aligned(targetModel.DefaultDimensionStyle);
dxfDimension.ExtensionLine1StartPoint = new Point3D(location.X, location.Y, location.Z);
dxfDimension.ExtensionLine2StartPoint = new Point3D(rightLocation.X, rightLocation.Y, rightLocation.Z);
dxfDimension.DimensionStyleOverrides.TextHeight = 56d;
dxfDimension.DimensionStyleOverrides.ArrowSize = 56d;
dxfDimension.Text = getDimensionText(dxfDimension);
targetModel.Entities.Add(dxfDimension);
}
}
DxfDimension.Aligned wholeDxfDimension = new DxfDimension.Aligned(targetModel.DefaultDimensionStyle);
wholeDxfDimension.ExtensionLine1StartPoint = new Point3D(firstDimensionLocation.X, firstDimensionLocation.Y, firstDimensionLocation.Z);
wholeDxfDimension.ExtensionLine2StartPoint = new Point3D(lastDimensionLocation.X, lastDimensionLocation.Y, lastDimensionLocation.Z);
wholeDxfDimension.DimensionStyleOverrides.TextHeight = 56d;
wholeDxfDimension.DimensionStyleOverrides.ArrowSize = 56d;
wholeDxfDimension.Text = getDimensionText(wholeDxfDimension);
wholeDxfDimension.DimensionLineLocation = new Point3D(firstDimensionLocation.X+lastDimensionLocation.X,firstDimensionLocation.Y-1000,firstDimensionLocation.Z);
targetModel.Entities.Add(wholeDxfDimension);
DxfDimension.Aligned rightDimension = new DxfDimension.Aligned(targetModel.DefaultDimensionStyle);
rightDimension.ExtensionLine1StartPoint = new Point3D(lastDimensionLocation.X, lastDimensionLocation.Y, lastDimensionLocation.Z);
rightDimension.ExtensionLine2StartPoint = new Point3D(rightTopDimensionLocation.X, rightTopDimensionLocation.Y, rightTopDimensionLocation.Z);
rightDimension.DimensionStyleOverrides.TextHeight = 56d;
rightDimension.DimensionStyleOverrides.ArrowSize = 56d;
rightDimension.Text = getDimensionText(rightDimension);
rightDimension.DimensionLineLocation = new Point3D(largestLocation.X + 200, firstDimensionLocation.Y, firstDimensionLocation.Z);
targetModel.Entities.Add(rightDimension);
//绘制俯视图
for (int i = 0; i < dxfTopViewList.Count;i++ )
{
DxfModel topViewSourceModel = new DxfModel();
topViewSourceModel = DxfReader.Read(dxfTopViewList[i]);
if (i == 0)
{
topViewLocation = new DLocation(firstDimensionLocation.X, rightTopDimensionLocation.Y + RelativeDistance.yTopViewDistance, firstDimensionLocation.Z);
topViewRelativeLocation = getTopViewRelativeStartLocation(topViewSourceModel);
}
else
{
topViewLocation = topViewRightLocation;
DxfModel filterModel = getFilterBottomNotLineDxfModel(topViewSourceModel);
topViewRelativeLocation = getTopViewRelativeStartLocation(filterModel);
}
foreach(DxfEntity entity in topViewSourceModel.Entities)
{
DxfEntity clonedEntity = (DxfEntity)entity.Clone(cloneContext);
clonedEntity = getCaculateLocationEntity(clonedEntity, topViewLocation, topViewRelativeLocation);
targetModel.Entities.Add(clonedEntity);
}
topViewRightLocation = getTopViewNextStartLocation(positionList);
positionList.RemoveAll(name=>{return true;});
}
// 复制frame框体
DxfModel sourceFrameModel = new DxfModel();
sourceFrameModel = DxfReader.Read(frameName);
DLocation frameLeftDownLocation = getFrameLeftDownLocation(sourceFrameModel);
frameLastLineX = getFrameLastVerticalLineX(sourceFrameModel);
Point2D frameRightPoint2D = getFrameRightPoint(sourceFrameModel);
//这里求的是宽度比较,因为Frame的最后位置还没确定,不能单纯的考个别点进行位置大小比较
if ((largestLocation.X-firstDimensionLocation.X+RelativeDistance.xDistance)>= (frameRightPoint2D.X-frameLeftDownLocation.X))
{
RelativeDistance.increaseWidth = (largestLocation.X - firstDimensionLocation.X + RelativeDistance.xDistance) - (frameRightPoint2D.X - frameLeftDownLocation.X) + RelativeDistance.xDistance;
}
else
{
RelativeDistance.increaseWidth = 0;
}
foreach (DxfEntity entity in sourceFrameModel.Entities)
{
DxfEntity clonedEntity = (DxfEntity)entity.Clone(cloneContext);
clonedEntity = getFrameEntity(clonedEntity, firstDimensionLocation, frameLeftDownLocation, RelativeDistance.increaseWidth);
targetModel.Entities.Add(clonedEntity);
}
//传递表单数据值
foreach(TextValue textValue in textValueList){
foreach(TextValue transFormValue in valueList){
if (textValue.text.Equals(transFormValue.text))
{
DxfText dxfText = new DxfText();
dxfText.Text = transFormValue.value;
dxfText.Height = textValue.height;
dxfText.Thickness = 0.5d;
dxfText.AlignmentPoint1 = new Point3D(textValue.valuePosition.X, textValue.valuePosition.Y, textValue.valuePosition.Z);
dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1;
targetModel.Entities.Add(dxfText);
}
}
}
cloneContext.ResolveReferences();
DxfWriter.Write("cloneTest.dxf", targetModel);
}