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: 

ILogic Drawing Sheet Size Detection

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
phillip.shields
1448 Views, 3 Replies

ILogic Drawing Sheet Size Detection

Hello,

 

I've got a script that is suppose to:

 1. Open a drawing from the list provided in a table

 2. Detect the sheet size of the open document(from the table list).

 3. show a message box telling me what size the sheet is.

 

I can't get the sheet size to display properly. Any help guys?

 

		''' Set a reference to the drawing document.
		''' This assumes a drawing document is active.
		Dim oDrawDoc As DrawingDocument
		oDrawDoc = ThisApplication.ActiveDocument
		Dim sheet1 as Sheet = oDrawDoc.Sheets("Sheet:1")
		Dim table As CustomTable = sheet1.CustomTables.Item(1)
		Dim oRow As Row
		
		
		''' Iterate through the contents of the parts list.
		i = 1
		While i <= table.Rows.Count
		
		oRow = table.Rows.Item(i)
		Dim oCell As Cell = oRow.Item(2)
		iDoc = iProperties.Value("Summary", "Category") & "\" & oCell.Value & ".idw"

		Dim oDoc As DrawingDocument = ThisApplication.Documents.Open(iDoc)
		Dim oSheet As Sheet = oDoc.ActiveSheet
'		Dim MechCheck as String = oCell.Value
		
		If oSheet.Size = "B" Then 
		
			MessageBox.Show("B", "Title")
			
		Else If oSheet.Size = "D" Then 
		
			MessageBox.Show("D", "Title")
		
		End If
		
		'you may also save And close this drawing document
		oDoc.Save
		oDoc.Close
			
		i = i+1
		
		On Error Resume Next
		
		End While

 

3 REPLIES 3
Message 2 of 4
VdVeek
in reply to: phillip.shields

This code only gives you a message box when the sheet size is an B or an D. If you want to see the sheet size, place after:  

Dim oDoc As DrawingDocument = ThisApplication.Documents.Open(iDoc)
Dim oSheet As Sheet = oDoc.ActiveSheet

MessageBox.Show("Sheet Size = " & oSheet.Size, "Title") 

Did you write this code yourself? What is it you want to accomplish with this code?

This code need some changes i think, but that depends on you needs.

Rob.

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
Message 3 of 4
phillip.shields
in reply to: VdVeek

Well I kinda dumb down the code for the purpose of the message board becuase the only part I'm having trouble with is getting it to recognize the open drawing's sheet size. It opens the drawings and shows the message box but It is not showing the correct size. For example the sheet size will be "D" but the message box will show "B".

Message 4 of 4
phillip.shields
in reply to: VdVeek

You actually helped me solve the problem. I was looking for a way to distinguish between "B" and "D" size by letter but oSheet.Size is a "Double" not a "String". So I used you sheet size message box to get the actual size and was able to apply that to the code I was writing. Thanks for the quick respone.

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

Post to forums  

Autodesk Design & Make Report