dwg sheet size in custom model iprop

dwg sheet size in custom model iprop

JamieSENG
Advocate Advocate
1,027 Views
6 Replies
Message 1 of 7

dwg sheet size in custom model iprop

JamieSENG
Advocate
Advocate

Hi guys,

 

Ive been searching for a way to have the sheet property "sheet size" in are dwg title block transfer on saving to a custom property in the model under "paper size".

 

This is so when it comes to printing drawings we can identify what size and which printer to use.

 

Ive hit a brick wall in my attempts of writting an ilogic code to do this so im putting out there to anyone who may know.

 

We use one dwg template and title block which when its required we edit sheet and select the paper size needed. That size we select updates in the title block. When i edit the title block the options i have in sheet properties are sheet number, revision and size.

 

Look forward to your replies...

0 Likes
Accepted solutions (1)
1,028 Views
6 Replies
Replies (6)
Message 2 of 7

Vladimir.Ananyev
Alumni
Alumni

All texts in the TitleBlock object are stored in the TextBox objects.

  • TitleBlock.Definition property  ->  TitleBlockDefinition object
  • TitleBlockDefinition.Sketch property  ->  DrawingSketch object 
  • DrawingSketch.TextBoxes Property  ->  TextBoxes collection 

The TextBoxes collection provides access to all the existing TextBox objects in this Sketch. 

Here is the VBA snippet that prints texts stored in all TextBoxes in the current TitleBlock

Sub TextBoxesInTitleBlock()

    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
    
    Dim oTitleBlock As TitleBlock
    Set oTitleBlock = oSheet.TitleBlock
    
    ' Obtain a reference to the title block defintion.
    Dim oDef As TitleBlockDefinition
    Set oDef = oTitleBlock.Definition
    
    Dim oSketch As DrawingSketch
    Set oSketch = oDef.sketch

    Dim oTextBoxes As TextBoxes
    Set oTextBoxes = oSketch.TextBoxes
    
    Debug.Print "Total number: " & oTextBoxes.Count
    Debug.Print "Content: "
    Dim i As Integer
    Dim St As String
    Dim oBox As TextBox
    For i = 1 To oTextBoxes.Count
        Set oBox = oTextBoxes.Item(i)
        St = oBox.Text
''        St = oBox.FormattedText
        Debug.Print i, St
    Next i

End Sub

Here is the result I got with the newly created drawing sheet:

Total number: 19
Content: 
 1            <Sheet number>
 2            <Sheet Size>
 3            <TITLE>
 4            <PART NUMBER>
 5            State
 6            Changes
 7            Date
 8            Name
 9            Drawn
 10           Checked
 11           Standard
 12           Date
 13           Name
 14           <CREATION DATE>
 15           <CHECKED DATE>
 16           <ENG APPROVAL DATE>
 17           <AUTHOR>
 18           <ENG APPROVED BY>
 19           <CHECKED BY>

The Sheet size in my title block is stored in the box #2.
So we may save it’s text in the custom iProperty:
iProperties.Value("Custom", "Sheet Size") = oTextBoxes.Item(2).Text

 

Hope this could help you to develop the iLogic rule that suits your needs.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 7

JamieSENG
Advocate
Advocate

Can you elabarate? I ran it but it did nothing..

0 Likes
Message 4 of 7

Vladimir.Ananyev
Alumni
Alumni

I’ve got the following text boxes list for your template:

Total number: 30
Content: 
 1            PROJECT:
 2            TITLE:
 3            DRAWINGNUMBER:
 4            REV:
 5            <PROJECT>
 6            <REVISION NUMBER>
 7            MATERIAL:
 8            FINISH:
 9            <DESCRIPTION>
 10           <Finish>
 11           SCALE:
 12           <Scale>
 13           SIZE:
 14           Test Company
 15           ENGLAND.
 16           TEL: FAX:
 17           DRAWN BY:
 18           <AUTHOR>
 19           CREATED:
 20           <CREATION DATE>
 21           THIRD ANGLE PROJECTION
 22           MACHININGUP TO 100 ±0.15101 TO 300 ±0.40301 TO 1000 ±0.80MACHINED SURFACE FINISH 3.2um
 23           FABRICATIONUP TO 300 ±1.0301 TO 1000 ±2.01000 & ABOVE ±3.0
 24           TOLERANCES U.O.S.
 25           DO NOT SCALE DRAWING
 26           ALL DIMENSIONS IN mm U.O.S.
 27           THIS DRAWING SHOULD NOT BE COPIEDOR PASSED TO A THIRD PARTYWITHOUT THE WRITTEN CONSENT.
 28           <PART NUMBER>
 29           <Sheet Size>
 30           <TITLE>
LE PROJECTION
 22           MACHININGUP TO 100 ±0.15101 TO 300 ±0.40301 TO 1000 ±0.80MACHINED SURFACE FINISH 3.2um
 23           FABRICATIONUP TO 300 ±1.0301 TO 1000 ±2.01000 & ABOVE ±3.0
 24           TOLERANCES U.O.S.
 25           DO NOT SCALE DRAWING
 26           ALL DIMENSIONS IN mm U.O.S.
 27           THIS DRAWING SHOULD NOT BE COPIEDOR PASSED TO A THIRD PARTYWITHOUT THE WRITTEN CONSENT.
 28           <PART NUMBER>
 29           <Sheet Size>
 30           <TITLE>

The field “<Sheet Size>” is stored in the text box #29. 

Now we may use the method TitleBlock.GetResultText(TextBox) to get the text that is currently displayed for this text box with prompted text.

Set oBox = oTextBoxes.Item(29)
St = oTitleBlock.GetResultText(oBox)
MsgBox (St)

St returns the sheet size “A3”.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 7

JamieSENG
Advocate
Advocate

What version did you do this in because when i ran it using ilogic in inventor 2015 it results in errors.

1) 'Let' and 'set' assignment statements are no longer supported

2) oTextBoxes is not declared. It may be inaccessible due to its protection level

3) oTitleblock is not declared. It may be inaccessible due to its protection level

 

Also i did manage to get the previous vba to run and found the sheet text block to be #29

 

I dont no was i clear on what i wanted to achieve. Or i may be understanding you wrong. This method you suggest does it display the sheet size in a promt like box in the drawing? If so it wouldnt be of any use displaying the size has its already on the sheet. I want to have it send/transfer that sheet size value to a custom iproperty in the model that 'would be' in the drawing. 

 

Thanks

0 Likes
Message 6 of 7

Vladimir.Ananyev
Alumni
Alumni

That was VBA code, not iLogic.  This explains why you got those errors in iLogic ('Let' and 'set', and so on).

If you already got the sheet size somehow and want to save it in the custom iProperty, you may use iLogic function

iProperties.Value("Custom", "Paper size") = size

 

Here is the iLogic snippet:

'reads sheet size from the Title Block
'and saves it in the custom iProperty

'active sheet
Dim oSheet As Sheet = ActiveSheet.Sheet
'reference to the existing title block
Dim oTitleBlock As TitleBlock = oSheet.TitleBlock
' Obtain a reference to the title block defintion.
Dim oDef As TitleBlockDefinition = oTitleBlock.Definition
'this sketch contains the collection of all text boxes of the title block
Dim oSketch As DrawingSketch = oDef.Sketch
'reference to the text box that stores Sheet Size string
'in this template it is the 29th text box in the collection
Dim oBox As TextBox = oSketch.TextBoxes.Item(29)
'read the sheet size
Dim size As String  = oTitleBlock.GetResultText(oBox)
'save data in the custom iProperty
iProperties.Value("Custom", "Paper size") = size

'this message is for debug purpose only
MsgBox("Paper size saved:   " & size)

cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 7 of 7

JamieSENG
Advocate
Advocate
Accepted solution

I think you may still have got the wrong idea of what i was trying to achieve. I have however finally been able to find a solution using what you did.

 

Take note of custom iproperties in the .ipt... Insert the part into the drawing and run the code, check .ipt properties again.... there appears the sheet size. Ill now use a custom property in the bill of materials so this value for each part appears. This will go nicely in identifying what printing settings i should use. You see i'm using inventor task scheduler, sequential task to batch print so i tend to be setting up a A1,2 and 3 batch of drawings which up to now I've had to do separately has guesstimating has been judged by looking at the tiny little thumbnail preview.

 

Anyway Id appreciate your feedback if you wouldn't mind. 

 

Also I did read another person asking about this with no look up to now so i hope that this will be of use to them or anyone for that matter.

 

Thank you Vladimir

 

 

0 Likes