Get sheet format

Get sheet format

martinhoos
Advocate Advocate
1,193 Views
6 Replies
Message 1 of 7

Get sheet format

martinhoos
Advocate
Advocate

Hi all,

i like to have a code that insert sketched symbols in the right corner of my sheet. The Goal is, i have more than one different Sheets (A4, A3...) in my IDW. 

How can i get the different sheet-formats (A4, A3....), so that i can calculate the right lower corner to get the insert point.

 

For Each oSheet In oIDW.Sheets
		Dim Format As String
		Format = ActiveSheet.Size
		MessageBox.Show(Format, "Title")
Next

 

The above code only gets the format from the first side...

 

Who can help me?

 

Regards an a nice Weekend ...

 

Martin

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

GeorgK
Advisor
Advisor

On Error Resume Next
            Select Case oDrgDoc.ActiveSheet.Size
                Case kA4DrawingSheetSize
                   
                Case kA3DrawingSheetSize
                  
                Case kA2DrawingSheetSize
                 
                Case kA1DrawingSheetSize
                  
                Case kA0DrawingSheetSize
                   
                Case Else    ' Andere Werte.
                   
            End Select

0 Likes
Message 3 of 7

dgreatice
Collaborator
Collaborator
Dim oIDW as drawingdocument
Dim osheet as sheet

For Each oSheet In oIDW.Sheets
Select case osheet.size
Case kA4DrawingSheetSize
Msgbox ("A4")
Case kA3DrawingSheetSize
Msgbox ("A3")
End select
Next
Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 4 of 7

martinhoos
Advocate
Advocate

Thank you for your reply. I dont know where i have to put your code in. Pls can you change my code with yours? 

Thank you very much.

Regards Martin

 

Dim oIDW As DrawingDocument
oIDW = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oIDW.ActiveSheet
Dim oLayers As LayersEnumerator = oSheet.Parent.StylesManager.Layers
Dim sFormatName As String


For Each oSheet In oIDW.Sheets
If ActiveSheet.Size = "A4" Then 
sFormatName = "A4"
MessageBox.Show(sFormatName , "iLogic")

ElseIf ActiveSheet.Size = "A3" Then 
sFormatName = "A3"
MessageBox.Show(sFormatName , "iLogic")

End If
Next
0 Likes
Message 5 of 7

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @martinhoos,

 

Basically, Sheet.Size property returns DrawingSheetSizeEnum Enumerator not a string value.Try the following changes in your code.

 

Dim oIDW As DrawingDocument
oIDW = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oIDW.ActiveSheet
Dim oLayers As LayersEnumerator = oSheet.Parent.StylesManager.Layers
Dim sFormatName As String


For Each oSheet In oIDW.Sheets
If oSheet.Size = kA4DrawingSheetSize Then 
sFormatName = "A4"
MessageBox.Show(sFormatName , "iLogic")

ElseIf oSheet.Size = kA3DrawingSheetSize Then 
sFormatName = "A3"
MessageBox.Show(sFormatName , "iLogic")

ElseIf oSheet.Size = kA2DrawingSheetSize Then
sFormatName = "A2"
MessageBox.Show(sFormatName , "iLogic")

ElseIf oSheet.Size = kA1DrawingSheetSize Then
sFormatName = "A1"
MessageBox.Show(sFormatName , "iLogic")

ElseIf oSheet.Size = kA0DrawingSheetSize Then
sFormatName = "A0"
MessageBox.Show(sFormatName , "iLogic") End If Next

Refer the following link for more details about DrawingSheetSizeEnum Enumerator

 

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-55595BC5-77E1-485D-861D-B1FE827EE132

 

Please feel free to contact if there is any queries.

 

If problem solved, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 6 of 7

martinhoos
Advocate
Advocate

Hi chandra.shekar.g,

thank you for your reply. I tried your code, but i get no result. May be, because we are using Inventor 2015?

If i copy this line:  

MessageBox.Show(sFormatName , "iLogic")

to the end of your code - the window is emty.

 

 Regards

Martin

0 Likes
Message 7 of 7

martinhoos
Advocate
Advocate
Accepted solution

Hello chandra.shekar.g,

I placed DrawingSheetSizeEnum in front of kA4DrawingSheetSize and it runs.....

Thanks again for your support

Regards Martin

 

 

 

Dim oIDW As DrawingDocument
oIDW = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oIDW.ActiveSheet
Dim oLayers As LayersEnumerator = oSheet.Parent.StylesManager.Layers
Dim sFormatName As String


For Each oSheet In oIDW.Sheets
If oSheet.Size = DrawingSheetSizeEnum.kA4DrawingSheetSize Then 
sFormatName = "A4"
MessageBox.Show(sFormatName , "iLogic")

ElseIf oSheet.Size = DrawingSheetSizeEnum.kA3DrawingSheetSize Then 
sFormatName = "A3"
MessageBox.Show(sFormatName , "iLogic")

ElseIf oSheet.Size = DrawingSheetSizeEnum.kA2DrawingSheetSize Then 
sFormatName = "A2"
MessageBox.Show(sFormatName , "iLogic")

ElseIf oSheet.Size = DrawingSheetSizeEnum.kA1DrawingSheetSize Then 
sFormatName = "A1"
MessageBox.Show(sFormatName , "iLogic")

ElseIf oSheet.Size = DrawingSheetSizeEnum.kA0DrawingSheetSize Then 
sFormatName = "A0"
MessageBox.Show(sFormatName , "iLogic")

End If
Next

0 Likes