REFERENCE IPROPERTY OF ASSEMBLY IN FIRST VIEW OF DRAWING

REFERENCE IPROPERTY OF ASSEMBLY IN FIRST VIEW OF DRAWING

SECOJOSE
Contributor Contributor
269 Views
5 Replies
Message 1 of 6

REFERENCE IPROPERTY OF ASSEMBLY IN FIRST VIEW OF DRAWING

SECOJOSE
Contributor
Contributor

This should be simple a simple request. Im looking for how to reference a custom property of the assembly in the first view of a drawing.

0 Likes
270 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

Hi @SECOJOSE.  If the assembly is being directly referenced by the drawing view, then this is relatively easy to do 'manually', but can be pretty complicated to do by code.

WCrihfield_0-1724349631128.png

When attempting to do this by code, without the aid of that user interface dialog, we need to work with the DrawingNote.FormattedText property, and we also need to know how to use XML tags to not only format how the test looks, but what 'derived properties' are included within the text.  There is an online help documentation page this, but it is very brief, and does not include much examples.

XML Tags for FormattedText 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 6

SECOJOSE
Contributor
Contributor

Im aware of how to do this in text boxes. Unfortunately, i need this for code. You mean to tell me that you can access a model's parameters but cannot access custom properties without complicated code? 

 

Obviously, a work around would be to move the information from the custom property to a user parameter but would prefer to do this by referencing the custom prop itself.

0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor

We can certainly get the value of the custom iProperty from the model being referenced in the view, then simply put that 'static' value into a drawing note.  But putting it into the note in a way that remains 'linked / live', so that if the value in the model changes, it will automatically update in that drawing note,  is where it gets complicated.  It's not impossible, though.  The easiest way to learn how to do it is by reverse engineering it.  What I mean is, create the note exactly the way you want it to be manually, then use some simple inspection code to check the contents of its FormattedText to see how the changes you made in the manual dialog effect the contents of the FormattedText contents.  Below is an example inspection code you can use in an iLogic rule.  It will write the contents of the FormattedText to the iLogic Log window.

Dim oDNote As DrawingNote = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingNoteFilter, "Select a drawing note to inspect.")
If oDNote Is Nothing Then Return
Logger.Info(vbCrLf & oDNote.FormattedText)

Another good way to get the 'feedback' in a 'selectable' way is to use an InputBox, and put the FormattedText where the 'default value' should be, that way it is within the interactive textbox area when it shows.

Leaving for the day now, but will check back tomorrow, if needed.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 6

SECOJOSE
Contributor
Contributor

I may have not described the problem well. The application was to have a drawing property match the same property in the attached assembly. The solution i was looking for would be similar to the following snippet, only specific to the first view on a sheet:

 

iProperties.Value("Project", "Description") = iProperties.Value("ASSYNAME.iam", "Project", "Description")

 

I currently have this set up dynamically to where the drawing and assembly have the same name and "ASSYNAME" is determined by thisdoc but would like it change per sheet. 

0 Likes
Message 6 of 6

WCrihfield
Mentor
Mentor

Hi @SECOJOSE.  Going by the code example you showed, with the fact that you want this to be a 'per sheet' scenario, one problem comes to mind.  The drawing only has one iProperty named 'Description', so if you try to write a different value to that one iProperty per each sheet of the drawing, only the last value will be kept, because it will keep getting overwritten.

 

However, since I may still not be understanding something properly, I will mention something else that you may find interesting or useful in this area.  The DrawingView Inventor API object has a fairly new (added in 2023 version of Inventor) property (DrawingView.IsTextPropertySource).  That can only be set to True when the DrawingView is a 'base view'.  When set to True, that means that the model document being 'directly' referenced by that view, on that sheet, will be the 'default source model' for any annotations on that sheet that are 'linked' to 'the model'.  However, I believe this only effects those user interface tools within the Format Text dialog, where you can drop links to model data into your annotations.  I do not think this will have any effect on if you are accessing these things by code.  Before 2023, the first view of the first model that was placed in the whole drawing, was used as the 'default source model' for all 'linked' properties in all annotations in the whole drawing.

 

So, since there is only one 'Description' iProperty for the whole drawing, stored at the drawing document level, then where is the description of the model being referenced within the first view on each sheet supposed to be stored?  If you think I am still not understanding something correctly, then maybe some screen captured images would help, and maybe explaining the manual steps you are currently taking in as much detail as possible, would help explain this situation better.

 

Below is some example iLogic rule code which will get the current drawing, active sheet, first view on that sheet (if any), then its referenced document.  Then it will get the 'Description' iProperty value from that referenced document, and set that as the value of the drawing document's main 'Description' iProperty.  There is no PropertySet owned by the drawing per sheet of a drawing though.

Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, Inventor.DrawingDocument)
If oDDoc Is Nothing Then Return
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
If oSheet.DrawingViews.Count = 0 Then Return
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)
Dim oViewDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim sModelDesc As String = oViewDoc.PropertySets.Item(3).Item(14).Value 'Description iProperty
oDDoc.PropertySets.Item(3).Item(14).Value = sModelDesc

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes