Help: iLogic Format Text for 3D Annotate Notes (General Note)

Help: iLogic Format Text for 3D Annotate Notes (General Note)

ngdnam88
Advocate Advocate
1,685 Views
12 Replies
Message 1 of 13

Help: iLogic Format Text for 3D Annotate Notes (General Note)

ngdnam88
Advocate
Advocate

Dear All,

Please help me the iLogic Code can setting the Format Text for 3D Annotate Notes (General Note)? Thanks,

A004.PNG

0 Likes
Accepted solutions (2)
1,686 Views
12 Replies
Replies (12)
Message 2 of 13

theo.bot
Collaborator
Collaborator
Accepted solution

The Notes contains formatted text. To create the formatted text correctly is maybe not that easy. So i would do it like this:

 

create a general note, link all the parameters and format the text as you would like.

Then run this small rule (make sure the ilogic logger tab is visible)

Dim oDoc As PartDocument
oDoc = ThisDoc.Document 

'Logger.Info(oDoc.ComponentDefinition.ModelAnnotations.ModelGeneralNotes.Item(1).Definition.Text.FormattedText)

Then copy the text from the logger screen:

theobot_0-1634363570575.png

 



now you can create a external rule and use (paste)  your formatted text:

Dim oDoc As PartDocument
oDoc = ThisDoc.Document 

'Logger.Info(oDoc.ComponentDefinition.ModelAnnotations.ModelGeneralNotes.Item(1).Definition.Text.FormattedText)

oFormat = "Partnumber:<Property Document='model' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property><Br/>Material: <Property Document='model' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='20'>MATERIAL</Property><Br/>Mass: <PhysicalProperty PhysicalPropertyID='72449' Precision='2'>MASS</PhysicalProperty>"
'create definition
Dim oGennotedef As ModelGeneralNoteDefinition
oGennotedef= oDoc.ComponentDefinition.ModelAnnotations.ModelGeneralNotes.CreateDefinition(oFormat, True, ScreenQuadrantEnum.kLowerRightQuadrant)
'add to model
Dim oGennote As ModelGeneralNote
oGennote = oDoc.ComponentDefinition.ModelAnnotations.ModelGeneralNotes.Add(oGennotedef)
	

 

Message 3 of 13

ngdnam88
Advocate
Advocate

Thanks @theo.bot 

How about the setting Font + Text Size?. Could you please help me. Thanks,

0 Likes
Message 4 of 13

theo.bot
Collaborator
Collaborator
Accepted solution

It works the same. By default the text style is defines the font and size. But if you make changes to your first definition than the formatted text will include this info:

theobot_0-1634377028672.png

 

Message 5 of 13

ngdnam88
Advocate
Advocate
Thanks you very much!
Message 6 of 13

cparnellCDZ7D
Enthusiast
Enthusiast

@theo.bot, since I don't know iLogic I am not sure if post will help me. I am trying to find a way to automate 3D Annotate to default to, Type: Standard iProperties and Properties: PART NUMBER.

I created a routine with your code:

Dim oDoc As PartDocument
oDoc = ThisDoc.Document

'Logger.Info(oDoc.ComponentDefinition.ModelAnnotations.ModelGeneralNotes.Item(1).Definition.Text.FormattedText)

 

I ran it with iLogic Log dialog box showing and got the following:

Error Message:

Error on line 2 in rule: Annotate Part #, in document: HR-AY-0452.iam

Unable to cast COM object of type 'Inventor._DocumentClass' to interface type 'Inventor.PartDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{29F0D463-C114-11D2-B77F-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

 

More Info:

System.InvalidCastException: Unable to cast COM object of type 'Inventor._DocumentClass' to interface type 'Inventor.PartDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{29F0D463-C114-11D2-B77F-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
at ThisRule.Main() in external rule: Annotate Part #:line 2
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

Not sure what is going on. Would you be willing to help me out?

 

Autodesk Inventor Professional 2022
64-Bit Edition

Build: 350, Release: 2033.3 - Date: Wed 04/06/2022

 

Thank you for any help!

Have a great weekend.

0 Likes
Message 7 of 13

theo.bot
Collaborator
Collaborator

@cparnellCDZ7D 

 

It's because oDoc is declared as Part document and you are running it in a assembly.

 

You can update it to make it work in parts and assemblies:

 

Dim oDoc As Document
oDoc = ThisDoc.Document 

 

0 Likes
Message 8 of 13

cparnellCDZ7D
Enthusiast
Enthusiast

theo.bit

Thank you for your help!!

 

I changed my file to what you gave me.

cparnellCDZ7D_0-1659718894787.png

I generated my Format Text, have iLogic Log open. When I ran the routine, nothing shows in the iLogic Log window.

 

cparnellCDZ7D_2-1659719543413.png

 

Thank you again.

0 Likes
Message 9 of 13

theo.bot
Collaborator
Collaborator

@cparnellCDZ7D 

 

It looks like you created a leader note, not a general note. 

 

If you want to get the leader note info you could use something like this:

Dim oDoc As Document
oDoc = ThisDoc.Document 

Logger.Info(oDoc.ComponentDefinition.ModelAnnotations.ModelLeaderNotes.Item(1).Definition.Text.FormattedText)
0 Likes
Message 10 of 13

cparnellCDZ7D
Enthusiast
Enthusiast

First, thank you for your help.

Thank you for the update. Still trying to figure out the rest.

 

If you don't mind, this is what I have.

 

Dim oDoc As Document
oDoc = ThisDoc.Document

Logger.Info(oDoc.ComponentDefinition.ModelAnnotations.ModelLeaderNotes.Item(1).Definition.Text.FormattedText)

oFormat = "Property Document='model' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property"
'create definition
Dim oGennotedef As ModelLeaderNoteDefinition
oGennotedef= oDoc.ComponentDefinition.ModelAnnotations.ModelLeaderNotes.CreateDefinition(oFormat, True, ScreenQuadrantEnum.kLowerRightQuadrant)
'add to model
Dim oGennote As ModelGeneralNote
oGennote = oDoc.ComponentDefinition.ModelAnnotations.ModelLeaderNotes.Add(oGennotedef)


'I changed ModelGeneralNoteDefinition to ModelLeaderNoteDefinition line 8
'I changed .ModelGeneralNotes. to .ModelLeaderNotes. on line 9 & 12


'From iLogic Log
'Property Document='model' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property
'Get error on line 9.

'Error message
'Error on line 9 in rule: Annotate Part #, in document: 04.0-SSB-SSW-R0AA.iam
'
'Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

'More Info
'System.Runtime.InteropServices.COMException (0x80020005): Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
' at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
' at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
' at ThisRule.Main() in external rule: Annotate Part #:line 9
' at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
' at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

 

 

 

 

 

 

0 Likes
Message 11 of 13

theo.bot
Collaborator
Collaborator

@cparnellCDZ7D ,

 

You can't simply replace parts of the codes, because ModelGeneralnotes have different inputs then ModelLeadernodes. The generalNotes are easier, because the definition will require less input. With leader notes you need to define the annotation plane, associated geometry etc. 

 

 

Check the API help to find out what inputs are required in detail:

 

Inventor 2023 Help | ModelGeneralNotes.Add Method | Autodesk

 

Inventor 2023 Help | ModelLeaderNotes.Add Method | Autodesk

0 Likes
Message 12 of 13

cparnellCDZ7D
Enthusiast
Enthusiast

Thank you again. I'll keep working on it.

0 Likes
Message 13 of 13

vyivanchikov
Enthusiast
Enthusiast

Good day, everyone!
Can you please tell me how in the environment to pull more
G_L and G_B user data

0 Likes