I am trying to change the titleblock definition of a drawing when I run my custom ilogic code. Currently (and for the past few years) the drawing name is defined by the drawing properties part number but when I run my code I would like the drawing name to be defined by the model properties part number as shown below:
Currently the textbox for the part number is configured as below:
And I'd like to change it to this:
The code I have to find the part number is as follows:
Dim x = 1 Dim oTxtBox As Inventor.TextBox For Each oTxtBox In oDrawDoc.ActiveSheet.TitleBlock.Definition.Sketch.TextBoxes If oTxtBox.Text = "<PART NUMBER>" Then oStuff = oDrawDoc.ActiveSheet.TitleBlock.Definition.Sketch.TextBoxes(x) MessageBox.Show(oStuff.FormattedText, "Title") End If x += 1 Next
The result of the code is shown below:
I can't seem to change the property directly, when I try I receive an error like, "the value is read only"
Why do you want to update drawing in this way? Have you try Drawing Recources Transfer Wizard? It's better if you know names of drawing you want to update, it's like batch update.
edit:
using wizard you have to make a new block with model - part number and then update all other drawings.
Thanks for your reply.
I don't want to change too much. We are making incremental changes to the way we do things here and I want to test this method without permanently changing all our engineering drawings (we have many product lines and very many drawings.)
What I have done is create an ilogic program that consolidates all my idw's into one using the assembly or weldment drawing as the master document and all the component part and sub assembly drawings are added to the master document. This master document is then exported as a dwf which is then used in our ERP system.
The problem with the current titleblock definition is that the drawings added to the master drawing take on the master drawing's name and so the name of the component/sub assembly is lost. By changing the titleblock definition from 'drawing - part number' to 'model - part number', the drawing name then takes on the part number of the component/sub assembly and all is well.