I have found an problem with change text on drawing note trough API.
Situation:
Create leader note in empty drawing
Change text on this note with following code:
Public Sub Run() Dim oDoc As DrawingDocument Set oDoc = ThisApplication.ActiveDocument Dim oNotes As DrawingNotes Set oNotes = oDoc.ActiveSheet.DrawingNotes oNotes(1).FormattedText = "abcd" Debug.Print oNotes(1).Color.ColorSourceType End Sub
Then edit text stnadrda dialog, result is that color of text is changed from bylayer to overwited color.
Strange is that trough api is color still set as bylayer.
I am not able to find how to coerrect it.
Inventor 2013SP1
Thank you
Hi,
What I saw is slightly difference to yours. (also Inventor 2013 SP1)
2.1) The code returns the color type is kLayerColorSource . This is correct because the code modifies the text content only
2.2) The drawing shows the text is changed. And looks color is not changed.
2.3) when you open the text edit dialog of leader note manually right now, you can find the color has been changed to green!
3. Now, if you change to other color manually, and run your code again, the color type returns kOverrideColorSource >> correct.
4. If you modify the color manually right after you creating the leader note, the color type will also return kOverrideColorSource >> correct
So, the only problem to me is 2.3.
Could you double check at your side?
Hi,
yes, this is exactly the problem. I didnot find any pssibility to change the note text correctly yet. There is next problem that these text are wrongly exported to autocad , these text are exported in white color (expected is black acc.to layer).
Thank you
Petr
I am also seeing the inability to change text color regardless of options, still.
Also, I can't seem to get the command manager to open the edit text window and keep it open until Ok/cancel is pressed after it makes my deafult note.
Ideally I want the color to be automatic, but the kAutomatic setting wasn't working, so I tried override to see if that works and it didn't.
See code:
Sub Main() Dim oDoc As Document oDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet Dim oDrawingView As DrawingView Dim oModel As Document Dim oCompeDef As ComponentDefinition Dim oNoteText As String oNoteText = InputBox("Input Paint Note", "New Paint Note", "PAINT AS PER D-001") oNoteText = "<StyleOverride FontSize='0.39624' Underline='True'>NOTES:</StyleOverride><Br/><Br/><Numbering Format='1'>" & oNoteText & "</Numbering>" For j=1 To oDoc.Sheets.Count oSheet=oDoc.Sheets.Item(j) AddNote(oSheet, oNoteText) Next End Sub Sub AddNote(oSheet As Sheet, oNoteText As String) Dim oSS As SelectSet oSS = ThisApplication.ActiveDocument.SelectSet oSS.Clear Dim oTG As TransientGeometry Dim oCorner1 As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(61.4593464518012,9.36940229592981) Dim oCorner2 As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(82.5227559718543,14.3003427786209) oNote = oSheet.DrawingNotes.GeneralNotes.AddByRectangle(oCorner1, oCorner2, oNoteText,) With oNote .HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft 'kAlignTextCenter 19969 Text centered about the supplied point. 'kAlignTextLeft 19970 Text Left-justified about the supplied point. 'kAlignTextRight 19971 Text Right-justified about the supplied point. .VerticalJustification = VerticalTextAlignmentEnum.kAlignTextUpper 'kAlignTextBaseline 25604 Text positioned at the supplied point. Applies To Sketch text only. 'kAlignTextLower 25603 Text positioned below the supplied point. 'kAlignTextMiddle 25601 Text centered about the supplied point. 'kAlignTextUpper 25602 Text positioned above the supplied point. .Color.SetColor(255,255,255) .Color.ColorSourceType = ColorSourceTypeEnum.kOverrideColorSource 'oNote.Color.ColorSourceType = ColorSourceTypeEnum.kAutomaticColorSource 'kAutomaticColorSource 79106 The color Of the Object Is specified by automatic color. 'kLayerColorSource 79107 The color Of the Object Is specified by layer. 'kOverrideColorSource 79105 The color Of the Object has been overrided. End With 'oSS.Select(oNote) ' 'Dim oCommandMgr As CommandManager 'oCommandMgr = ThisApplication.CommandManager ' 'Dim oControlDef1 As ControlDefinition 'oControlDef1 = oCommandMgr.ControlDefinitions.Item("DrawingGeneralNoteEditCtxCmd") 'oControlDef1.Execute2(True) End Sub