change text on note

change text on note

petrxn
Advocate Advocate
1,347 Views
4 Replies
Message 1 of 5

change text on note

petrxn
Advocate
Advocate

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

0 Likes
1,348 Views
4 Replies
Replies (4)
Message 2 of 5

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

What I saw is slightly difference to yours. (also Inventor 2013 SP1)

 

  1. Create a leader note manually. In default, its color is bylayer
  2. Run your code.

     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?

0 Likes
Message 3 of 5

petrxn
Advocate
Advocate

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

0 Likes
Message 4 of 5

xiaodong_liang
Autodesk Support
Autodesk Support

I will log this issue. 

0 Likes
Message 5 of 5

MechMachineMan
Advisor
Advisor

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

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes