I am trying to create a dimension in a drawing off of a named edge in the part and I keep getting an error when I try to get the DrawingCurveEnumerator. Everything prior to that seems to work fine. I get the proper proxy which shows up in my debugger. If I don't filter the DrawingCurve property and just pick the first curve the dimension places correctly. It is exclusively when I try to filter the DrawingCurve property that I get an error.
for(int i = uniqueBaffles; i > 0; i--)
{
Point2d sideViewPoint = DrawingFuncts.LERPBox(usableBox, 0.75, 1 - (i * availableHeight) + (availableHeight * 0.5));
ComponentOccurrence componentOccurrence = assemblyDefinition.Occurrences[i];
Document baffleDocument = componentOccurrence.ReferencedDocumentDescriptor.ReferencedDocument;
DrawingView sideView = drawingViews.AddBaseView((_Document)baffleDocument, sideViewPoint, scale, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle);
if (firstBaffle)
{
DrawingFuncts.ScaleViewByPercentage(sideView, 0.4, availableHeight);
scale = sideView.Scale;
firstBaffle = false;
double dimensionGap = 3;
ObjectCollection topEdgeCollection = baffleDocument.AttributeManager.FindObjects("iLogicEntityNameSet", "iLogicEntityName", "Top Edge");
Edge topEdge = (Edge)topEdgeCollection[1];
object topEdgeProxy;
componentOccurrence.CreateGeometryProxy(topEdge, out topEdgeProxy);
//Invalid Argument error thrown here
DrawingCurvesEnumerator drawingCurveEnumerator = sideView.DrawingCurves[topEdgeProxy];
DrawingCurve topEdgeCurve = drawingCurveEnumerator[1];
GeometryIntent topEdgeIntent = firstSheet.CreateGeometryIntent(topEdgeCurve);
Point2d dimensionPoint = transientGeometry.CreatePoint2d(sideView.Center.X, sideView.Top + dimensionGap);
firstSheet.DrawingDimensions.GeneralDimensions.AddLinear(dimensionPoint, topEdgeIntent);
}
}
Hi @christopher.pepin . Your code looks fine, but there is a possibility that you are trying to get a curve from an edge that is hidden under another edge/plane. Maybe this is your case, make sure that your edge is displayed on the drawing.
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
Here is an example of what I mean. This is a plate that has edges on top(red) and bottom(blue), and when you have a DrawingView on top, you accordingly see only those curves that refer to the top edges and vice versa.
So you need to understand which side you see. This is a simple iLogic example (Try-Catch):
Dim oInvApp As Inventor.Application = ThisApplication
Dim oDDoc As DrawingDocument = oInvApp.ActiveDocument
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oView As DrawingView = oSheet.DrawingViews(1)
Dim oAsmDoc As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oOcc As ComponentOccurrence = oAsmDoc.ComponentDefinition.Occurrences(1)
Dim oPDoc As PartDocument = oOcc.Definition.Document
Dim oEdgeTop As Edge = oPDoc.AttributeManager.FindObjects("iLogicEntityNameSet", "iLogicEntityName", "TopTop")(1)
Dim oProxyTop As EdgeProxy : Call oOcc.CreateGeometryProxy(oEdgeTop, oProxyTop)
Dim oEdgeCurve As DrawingCurve
Try
oEdgeCurve = oView.DrawingCurves(oProxyTop)(1)
Catch
Dim oEdgeDown As Edge = oPDoc.AttributeManager.FindObjects("iLogicEntityNameSet", "iLogicEntityName", "TopBottom")(1)
Dim oProxyDown As EdgeProxy : Call oOcc.CreateGeometryProxy(oEdgeDown, oProxyDown)
oEdgeCurve = oView.DrawingCurves(oProxyDown)(1)
End Try
Dim oPoint As Point2d = oInvApp.TransientGeometry.CreatePoint2d(oView.Position.X, oView.Height/2 + oView.Position.Y + 1)
oSheet.DrawingDimensions.GeneralDimensions.AddLinear(oPoint, oSheet.CreateGeometryIntent(oEdgeCurve))
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
That seems to match my previous understanding and what I have.
I have my sketch set to the front view.
And if I look at my part the named edges are on the face that should be showing in the drawing. Ignore the stupid naming scheme, it made more sense when I was only naming faces.
Can't find what you're looking for? Ask the community or share your knowledge.