Message 1 of 13
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear All,
Please help me the iLogic Code can setting the Format Text for 3D Annotate Notes (General Note)? Thanks,
Solved! Go to Solution.
Dear All,
Please help me the iLogic Code can setting the Format Text for 3D Annotate Notes (General Note)? Thanks,
Solved! Go to 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:
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)
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:
@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.
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
theo.bit
Thank you for your help!!
I changed my file to what you gave me.
I generated my Format Text, have iLogic Log open. When I ran the routine, nothing shows in the iLogic Log window.
Thank you again.
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)
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)
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
Thank you again. I'll keep working on it.
Good day, everyone!
Can you please tell me how in the environment to pull more
G_L and G_B user data