Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
is there a way to link propeties to Drawing textbox link in following picture:
Solved! Go to Solution.
Hello,
is there a way to link propeties to Drawing textbox link in following picture:
Solved! Go to Solution.
Hello dg2405,
Do you want to add a <Filename> property to the end of the view label?
This code shows FormattedText of 1st (= base) view and copy it to the 2nd view label.
Sub test1() Dim drwDoc As DrawingDocument Set drwDoc = ThisApplication.ActiveDocument Dim activeSheet As Sheet Set activeSheet = drwDoc.activeSheet Debug.Print activeSheet.DrawingViews(1).Label.FormattedText MsgBox "FormattedText of the 1st view label is " & vbCr & activeSheet.DrawingViews(1).Label.FormattedText ' Copy Label format to the 2nd view. activeSheet.DrawingViews(2).Label.FormattedText = activeSheet.DrawingViews(1).Label.FormattedText End Sub
If you want to access GeneralNote, this code will help you.
Sub test2() Dim drwDoc As DrawingDocument Set drwDoc = ThisApplication.ActiveDocument Dim activeSheet As Sheet Set activeSheet = drwDoc.activeSheet Dim gNote As GeneralNote Set gNote = activeSheet.DrawingNotes.GeneralNotes(1) MsgBox "Original FormattedText is " & vbCr & gNote.FormattedText ' Create and copy general note. Dim location As Point2d Set location = ThisApplication.TransientGeometry.CreatePoint2d(5, 5) activeSheet.DrawingNotes.GeneralNotes.AddFitted location, gNote.FormattedText End Sub
The format of "FormattedText" is writen in the page XML Tags for FormattedText of API Help.
You can write it from scratch, but it's easy to write a template using Inventor UI and then copy the content of FormattedText into your code.
=====
Freeradical
Hideo Yamada
Hello dg2405,
Default FormattedText of view label is :
<DrawingViewName/> ( <DrawingViewScale/> )
Adding a filename property to the end of the label cause :
<DrawingViewName/> ( <DrawingViewScale/> )<Br/><DerivedProperty DerivedID='29700'>FILENAME</DerivedProperty>
The number of DerivedID is a member of DerivedPropertyTypeEnum and 29700 is kDerivedDrawingFilename.
As a result, this code will add a filename property to all of views.
Sub test3() Dim drwDoc As DrawingDocument Set drwDoc = ThisApplication.ActiveDocument Dim activeSheet As Sheet Set activeSheet = drwDoc.activeSheet Dim dView As DrawingView For Each dView In activeSheet.DrawingViews dView.Label.FormattedText = dView.Label.FormattedText & "<Br/><DerivedProperty DerivedID='" & kDerivedDrawingFilename & "'></DerivedProperty>" Debug.Print dView.Label.FormattedText Next End Sub
The text "FILENAME" as a content of DerivedProperty tag seems unnecessary.
If omitted, default text in your language is filled automatically.
("FILENAME" is set in English, and "ファイル名" is set in Japanese. "DATEINAME" will be set by your Inventor.)
=====
Freeradical
Hideo Yamada
Thank's this was very helpful. But when i want the iProperty "Part Number"? This Property is not available in the DerivedPropertyTypeEnum.
Hello,
@dg2405 wrote:Thank's this was very helpful. But when i want the iProperty "Part Number"? This Property is not available in the DerivedPropertyTypeEnum.
You can know what string should be added by inserting a property and checking FormattedText.
For example, I inserted [Properties - Drawing]->[PART NUMBER] manually and following string was added to the FormattedText.
<Property Document='drawing' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property>
Copy this string into your code that sets FormattedText.
=====
Freeradical
Hideo Yamada