- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am trying to create dimensions using edge naming by assigning names to the edges manually and then identifying them and creating dimensions but i am getting an unspecified error in the general dimension creation line below is the code used
public static void Create_Linear_Dimensions_EntityNaming(Inventor.DrawingView CurrView, string PartNameWithoutExt, string OccNameInAssy, string EdgeName1, string EdgeName2, DimensionTypeEnum DimType, double DimGap, bool boolAssembly)
{
try
{
drawingDoc = (DrawingDocument)invApp.ActiveDocument;
Sheet oSheet = drawingDoc.ActiveSheet;
PartDocument oPartDoc = null;
Inventor.AssemblyDocument oAssyDoc = null;
Inventor.ComponentOccurrence CompOcc = null;
Inventor.Document CurrDocument =(Inventor.Document) CurrView.ReferencedDocumentDescriptor.ReferencedDocument;
if (CurrDocument.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject)
{
oAssyDoc = (AssemblyDocument)CurrDocument;
DrgViewDocuments = new List<Inventor.Document>();
DrgViewCompOcc = new List<Inventor.ComponentOccurrence>();
GetAssyOccurences(oAssyDoc.ComponentDefinition.Occurrences, 0);
for (int i = 0; i <= DrgViewDocuments.Count - 1; i++)
{
CompOcc = DrgViewCompOcc[i];
Inventor.Document CurrDoc = DrgViewDocuments[i];
if ((System.IO.Path.GetFileNameWithoutExtension(CurrDoc.FullDocumentName).ToUpper() == (PartNameWithoutExt).ToUpper() && (CompOcc.Name).ToUpper() == (OccNameInAssy).ToUpper()))
{
oPartDoc = (PartDocument)CurrDoc;
break;
}
}
}
else if (CurrDocument.DocumentType == DocumentTypeEnum.kPartDocumentObject)
oPartDoc = (PartDocument)CurrDocument;
Edge Edge1, Edge2;
Inventor.ObjectCollection Obj1,Obj2;
Obj1 = invApp.TransientObjects.CreateObjectCollection();
Obj2 = invApp.TransientObjects.CreateObjectCollection();
Obj1 = oPartDoc.AttributeManager.FindObjects("iLogicEntityNameSet", "iLogicEntityName", EdgeName1);
//Edge1 = (Edge)Obj[1];
Obj2 = oPartDoc.AttributeManager.FindObjects("iLogicEntityNameSet", "iLogicEntityName", EdgeName2);
// Edge2 = (Edge)Obj[1];
Inventor.Point2d Point1, Point2;
double XPos, YPos;
DrawingCurvesEnumerator DrgCurveEnum;
DrawingCurve DrgCurve1 = null;
DrawingCurve DrgCurve2 = null;
object object1 = null, object2 = null;
EdgeProxy Edge1Proxy = null;
EdgeProxy Edge2Proxy = null;
try
{
if (boolAssembly == true)
{
CompOcc.CreateGeometryProxy(Obj1[1], out object1);
CompOcc.CreateGeometryProxy(Obj2[1], out object2);
Edge1Proxy = (EdgeProxy)object1;
Edge2Proxy = (EdgeProxy)object2;
}
else
{
DrgCurveEnum = CurrView.DrawingCurves[object1];
DrgCurve1 = DrgCurveEnum[1];
DrgCurveEnum = CurrView.DrawingCurves[object2];
DrgCurve2 = DrgCurveEnum[1];
}
} catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
XPos = CurrView.Left + (CurrView.Width / 2); YPos = CurrView.Top;
Point2d point2D = invApp.TransientGeometry.CreatePoint2d(XPos, YPos);
GeneralDimensions oGeneralDims;
oGeneralDims = oSheet.DrawingDimensions.GeneralDimensions;
GeneralDimension oDim;
oDim = (GeneralDimension)oGeneralDims.AddLinear(point2D, oSheet.CreateGeometryIntent(object1), oSheet.CreateGeometryIntent(object2), DimensionTypeEnum.kHorizontalDimensionType);//going to catch
}
catch (Exception ex) {
MessageBox.Show(ex.Message);
}
}
Solved! Go to Solution.