Adding chamfer note to drawing

Adding chamfer note to drawing

harvey_craig2RCUH
Advocate Advocate
708 Views
6 Replies
Message 1 of 7

Adding chamfer note to drawing

harvey_craig2RCUH
Advocate
Advocate

I would like to add a chamfer note to my drawing with iLogic. Here is how I'd place it in the UI:

harvey_craig2RCUH_0-1723719044137.png

Here is my code:

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDoc.ActiveSheet 'Sheet defined from document for access to chamfer notes.
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)'View defined to get the name as view defined by ThisDrawing only accepts itemByName
Dim viewname As String = oView.Name 'get view name
Dim MainSheet = ThisDrawing.ActiveSheet 'Sheet defined from drawing for use of GetIntents.
Dim VIEW1 = MainSheet.DrawingViews.ItemByName(viewname) 'View defined for GetIntents.

Dim ChamferFaceIntent As GeometryIntent = VIEW1.GetIntent("ChamferFace", nearPoint := VIEW1.SheetPoint(0.5, 0))' Get the geometry intents
Dim ChamferFace_PosX = VIEW1.GetIntent("ChamferFace", PointIntentEnum.kMidPointIntent).PointOnSheet.X * 10 - 20 'x10 to convert to mm, -20 to move it slightly way from the drawing
Dim ChamferFace_PosY = VIEW1.GetIntent("ChamferFace", PointIntentEnum.kMidPointIntent).PointOnSheet.Y * 10 - 20

Dim InternalFaceIntent As GeometryIntent = VIEW1.GetIntent("InternalFace", nearPoint := VIEW1.SheetPoint(0.5, 0)) 'Get Intent for internal diameter faces.

Dim oChamferNote As ChamferNote = oSheet.DrawingNotes.ChamferNotes.Add(ThisDrawing.Geometry.Point2d(ChamferFace_PosX, ChamferFace_PosY), ChamferFaceIntent, InternalFaceIntent)' Add the chamfer note.

 

And my error:

harvey_craig2RCUH_1-1723719129387.png

I'm having trouble with co-ordinates. Where have I gone wrong?

 

I have attached the files.

 

Thanks,

Harvey

 

0 Likes
Accepted solutions (2)
709 Views
6 Replies
Replies (6)
Message 2 of 7

Curtis_Waguespack
Consultant
Consultant

@harvey_craig2RCUH , thanks for providing the example ( that helps a lot)

 

To fix the error you are seeing, you can create a Point2D as shown:

Dim PositionPt As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(ChamferFace_PosX, ChamferFace_PosY)
Dim oChamferNote As ChamferNote = oSheet.DrawingNotes.ChamferNotes.Add(PositionPt, ChamferFaceIntent, InternalFaceIntent)' Add the chamfer note.

 

But there is still something it doesn't like about the intent edges... I didn't see the issue at a quick glance, but maybe it will be clear to you?

 

It just occurred to me that the remaining issue is we are mixing iLogic API GetIntent with Inventor API, which work differently.

 

ChamferNotes.add expects different objects than the iLogic GetIntent is providing.

A quick search found this:https://forums.autodesk.com/t5/inventor-programming-ilogic/create-chamfer-note-with-ilogic/td-p/8646...

 

https://help.autodesk.com/view/INVNTOR/2025/ENU/?guid=ChamferNotes_Add

EESignature

0 Likes
Message 3 of 7

Curtis_Waguespack
Consultant
Consultant
Accepted solution

@harvey_craig2RCUH , I took another look at this. This version creates the chamfer note, but the placement is not correct. I think you can work it out, now that you it will place the note on the sheet.

 

 

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDoc.ActiveSheet 'Sheet defined from document for access to chamfer notes.
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)'View defined to get the name as view defined by ThisDrawing only accepts itemByName
Dim viewname As String = oView.Name 'get view name
Dim MainSheet = ThisDrawing.ActiveSheet 'Sheet defined from drawing for use of GetIntents.
Dim VIEW1 = MainSheet.DrawingViews.ItemByName(viewname) 'View defined for GetIntents.

Dim oModelDoc = ActiveSheet.View("VIEW1").ModelDocument
oNamedEntities = iLogicVb.Automation.GetNamedEntities(oModelDoc)

Dim InternalFaceIntent As GeometryIntent = VIEW1.GetIntent("InternalFace", nearPoint := VIEW1.SheetPoint(0.5, 0)) 'Get Intent for internal diameter faces.
Dim ChamferFaceIntent As GeometryIntent = VIEW1.GetIntent("ChamferFace", nearPoint := VIEW1.SheetPoint(0.5, 0))' Get the geometry intents
Dim ChamferFace_PosX = VIEW1.GetIntent("ChamferFace", PointIntentEnum.kMidPointIntent).PointOnSheet.X * 10 - 20 'x10 to convert to mm, -20 to move it slightly way from the drawing
Dim ChamferFace_PosY = VIEW1.GetIntent("ChamferFace", PointIntentEnum.kMidPointIntent).PointOnSheet.Y * 10 - 20

Dim oFace1 As Face = oNamedEntities.FindEntity("ChamferFace")
Dim oFace2 As Face = oNamedEntities.FindEntity("InternalFace")

For Each oDrawingCurve As DrawingCurve In VIEW1.NativeEntity.DrawingCurves
	If oDrawingCurve.ModelGeometry Is oFace1 Then
		oChamferEdge1 = oDrawingCurve
	End If

	If oDrawingCurve.ModelGeometry Is oFace2 Then
		oChamferEdge2 = oDrawingCurve
	End If
Next

Dim PositionPt As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(ChamferFace_PosX, ChamferFace_PosY)
Dim oChamferNote As ChamferNote = oSheet.DrawingNotes.ChamferNotes.Add(PositionPt, oChamferEdge1, oChamferEdge2)' Add the chamfer note.

 

EESignature

0 Likes
Message 4 of 7

harvey_craig2RCUH
Advocate
Advocate

Hi Curtis,

 

Very helpful thanks for working that out for me. I have modified the code to incorporate positions in your model geometry section and removed my redundant GetIntents section. I have lost the nearPoint property which allowed me to select the chamfer shown on the bottom of the view. Do you know a work around for this?

Here is the updated code, noting else has changed in the file:

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDoc.ActiveSheet 'Sheet defined from document for access to chamfer notes.
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)'View defined to get the name as view defined by ThisDrawing only accepts itemByName
Dim viewname As String = oView.Name 'get view name
Dim MainSheet = ThisDrawing.ActiveSheet 'Sheet defined from drawing for use of GetIntents.
Dim VIEW1 = MainSheet.DrawingViews.ItemByName(viewname) 'View defined for GetIntents.

Dim oModelDoc = ActiveSheet.View("VIEW1").ModelDocument
oNamedEntities = iLogicVb.Automation.GetNamedEntities(oModelDoc)

Dim oFace1 As Face = oNamedEntities.FindEntity("ChamferFace")
Dim oFace2 As Face = oNamedEntities.FindEntity("InternalFace")

For Each oDrawingCurve As DrawingCurve In VIEW1.NativeEntity.DrawingCurves
	If oDrawingCurve.ModelGeometry Is oFace1 Then
		oChamferEdge1 = oDrawingCurve
		ChamferFace_PosX = oDrawingCurve.MidPoint.X : ChamferFace_PosY = oDrawingCurve.MidPoint.Y
	End If

	If oDrawingCurve.ModelGeometry Is oFace2 Then
		oChamferEdge2 = oDrawingCurve
	End If
Next

Dim PositionPt As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(ChamferFace_PosX + 2, ChamferFace_PosY + 2)
Dim oChamferNote As ChamferNote = oSheet.DrawingNotes.ChamferNotes.Add(PositionPt, oChamferEdge1, oChamferEdge2)' Add the chamfer note.
0 Likes
Message 5 of 7

harvey_craig2RCUH
Advocate
Advocate

Hi Curtis,

 

Another slight issue. In reality I would be making drawings of assemblies rather than parts and I'm having a little trouble with your if statement recognising the geometry if it's inside an assembly. I have modified the code to to reference the contained part but I still seem to have the aforementioned issue.

Here's the new code, I have also attached the files:

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDoc.ActiveSheet 'Sheet defined from document for access to chamfer notes.
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)'View defined to get the name as view defined by ThisDrawing only accepts itemByName
Dim viewname As String = oView.Name 'get view name
Dim MainSheet = ThisDrawing.ActiveSheet 'Sheet defined from drawing for use of GetIntents.
Dim VIEW1 = MainSheet.DrawingViews.ItemByName(viewname) 'View defined for GetIntents.

Dim oModelDoc = ActiveSheet.View(viewname).ModelDocument
Dim oAssemblyDoc As AssemblyDocument = oModelDoc
Dim oPartDoc As PartDocument = oAssemblyDoc.ComponentDefinition.Occurrences.ItemByName("SampleProfile:1").Definition.Document

oNamedEntities = iLogicVb.Automation.GetNamedEntities(oPartDoc)

Dim oFace1 As Face = oNamedEntities.FindEntity("ChamferFace")
Dim oFace2 As Face = oNamedEntities.FindEntity("InternalFace")

For Each oDrawingCurve As DrawingCurve In VIEW1.NativeEntity.DrawingCurves
    If oDrawingCurve.ModelGeometry Is oFace1 Then
        oChamferEdge1 = oDrawingCurve
        ChamferFace_PosX = oDrawingCurve.MidPoint.X
		MsgBox(ChamferFace_PosX) 'This doesn't print anything, therefore the if statement isn't working.
        ChamferFace_PosY = oDrawingCurve.MidPoint.Y
    End If

    If oDrawingCurve.ModelGeometry Is oFace2 Then
        oChamferEdge2 = oDrawingCurve
    End If
Next

Thanks,

Harvey

0 Likes
Message 6 of 7

Curtis_Waguespack
Consultant
Consultant
Accepted solution

@harvey_craig2RCUH 

 

When we work with an assembly there is intermediate geometry that Inventor creates as proxies.

 

So as written this line finds a proxy face in the assembly and not the actual part face.:

 If oDrawingCurve.ModelGeometry Is oFace1 Then

 

But we can use NativeObject on a proxy to get the geometry it is a proxy for, as shown below.

 

Also to figure out that the oDrawingCurve.ModelGeometry is returning a proxy, we an use something like shown to read it's type, and write it to the logger. Once we know that the object is a faceproxy, we can know to use the NativeObject by looking at the API reference for FaceProxy:

https://help.autodesk.com/view/INVNTOR/2025/ENU/?guid=GUID-FaceProxy

 

About the logger ( in case this is new to you) :

https://help.autodesk.com/view/INVNTOR/2025/ENU/?guid=GUID-BE996AA3-DE49-4765-86A7-129DD7B42A4A

 

For Each oDrawingCurve As DrawingCurve In VIEW1.NativeEntity.DrawingCurves
	Dim objT As ObjectTypeEnum = oDrawingCurve.ModelGeometry.Type
	Logger.Info(objT.ToString)
    If oDrawingCurve.ModelGeometry.NativeObject Is oFace1 Then
		
        oChamferEdge1 = oDrawingCurve
        ChamferFace_PosX = oDrawingCurve.MidPoint.X
		'MsgBox(ChamferFace_PosX) 'This doesn't print anything, therefore the if statement isn't working.
        ChamferFace_PosY = oDrawingCurve.MidPoint.Y
    End If

    If oDrawingCurve.ModelGeometry Is oFace2 Then
        oChamferEdge2 = oDrawingCurve
    End If
Next

 

EESignature

0 Likes
Message 7 of 7

harvey_craig2RCUH
Advocate
Advocate

All very helpful Curtis. Thank you again.

 

Here is the final code if anyone would like it in the future. I made the if statement create lists so you can choose exactly  which line you would like when a face creates multiple lines. 

 

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDoc.ActiveSheet 'Sheet defined from document for access to chamfer notes.
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)'View defined to get the name as view defined by ThisDrawing only accepts itemByName
Dim viewname As String = oView.Name 'get view name
Dim MainSheet = ThisDrawing.ActiveSheet 'Sheet defined from drawing for use of GetIntents.
Dim VIEW1 = MainSheet.DrawingViews.ItemByName(viewname) 'View defined for GetIntents.

Dim oModelDoc = ActiveSheet.View(viewname).ModelDocument
Dim oAssemblyDoc As AssemblyDocument = oModelDoc
Dim oPartDoc As PartDocument = oAssemblyDoc.ComponentDefinition.Occurrences.ItemByName("SampleProfile:1").Definition.Document

oNamedEntities = iLogicVb.Automation.GetNamedEntities(oPartDoc)

Dim oFace1 As Face = oNamedEntities.FindEntity("ChamferFace")
Dim oFace2 As Face = oNamedEntities.FindEntity("InternalFace")
Dim oChamferEdge1List As New ArrayList 
Dim oChamferEdge2List As New ArrayList
For Each oDrawingCurve As DrawingCurve In VIEW1.NativeEntity.DrawingCurves
	Dim objT As ObjectTypeEnum = oDrawingCurve.ModelGeometry.Type
    If oDrawingCurve.ModelGeometry.NativeObject Is oFace1 Then
		oChamferEdge1List.Add(oDrawingCurve)
    End If

    If oDrawingCurve.ModelGeometry.NativeObject Is oFace2 Then
		oChamferEdge2List.Add(oDrawingCurve)
    End If
Next

Dim PositionPt As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oChamferEdge1List(0).MidPoint.X + 2, oChamferEdge1List(0).MidPoint.Y - 2)
Dim oChamferNote As ChamferNote = oSheet.DrawingNotes.ChamferNotes.Add(PositionPt, oChamferEdge1List(0), oChamferEdge2List(0))' Add the chamfer note.