Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trouble creating dimension from EdgeProxy (C#)

4 REPLIES 4
Reply
Message 1 of 5
christopher.pepin
239 Views, 4 Replies

Trouble creating dimension from EdgeProxy (C#)

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);
    }
}

 

 

Labels (3)
4 REPLIES 4
Message 2 of 5

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.

EESignature

Message 3 of 5

@Andrii_Humeniuk So that is something I was trying to look into as it isn't clear to me how Inventor goes from a geometry proxy to selecting the appropriate drawing curves. I couldn't find anything on the topic and if you happen to have any resources on the topic I would love to see them.

In this case though I have a simple prism, just a single sketch extruded up with no drafts or anything. I have all the face named as well as the four edges visible from the front view of the part. The drawing view is set to the front view as well. Originally I was trying to grab the drawing curves from the face proxies of the two edges. When that didn't work I switch to trying to use the edge proxies of the front most edges and still no luck.
Message 4 of 5

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.

ViewEdges.png

TopDrawing.pngBottomDrawing.png

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.

EESignature

Message 5 of 5

That seems to match my previous understanding and what I have.

I have my sketch set to the front view.

christopherpepin_0-1713197072550.png

 

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.

christopherpepin_2-1713197239968.png

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report