Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get sheet format

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
martinhoos
983 Views, 6 Replies

Get sheet format

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

6 REPLIES 6
Message 2 of 7
GeorgK
in reply to: martinhoos

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

Message 3 of 7
dgreatice
in reply to: martinhoos

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
Message 4 of 7
martinhoos
in reply to: dgreatice

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
Message 5 of 7

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

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

Message 7 of 7
martinhoos
in reply to: martinhoos

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report