Sunday, November 21, 2010

Drawing Conclusions on Formatting a Drawing with iLogic

“Information is a source of learning. But unless it is organized, processed, and available to the right people in a format for decision making, it is a burden, not a benefit.”
William Pollard

As I was wrapping up my videos for the Autodesk Manufacturing Academy, I found a video that had slipped through the cracks.  I had recorded it, but I hadn't produced it.  So I finished it up and added it for this weeks post.

This video discusses how to change drawing formats with iLogic.


The finished rule asking you for the format you want to use
One more note before you look at the code below!  If you use event triggers, you can fire the rule automatically.  For example, the image below sets the drawing to fire it's rule when I start a new drawing.  If you set this from a template, the drawing will ask you which drawing format you want when you start it!

Use event triggers to fire a rule when a particular event happens. This one occurs when you start a new file
So without further delay, here's the video!

Here is the full code for this particular rule.  Once you get the first couple of rows down, it's a matter of copying, pasting, and changing options to get the others.


'Fires Rules when iTrigger icon is clicked
trigger = iTrigger0

'Creates a dialog box asking us which format we want
Format_Select= InputListBox("Select Format Type", MultiValue.List("Border_Type"), Border_Type, Title := "Drawing Format Selection", ListName := "List")

'Sets sheet size, title block, and border for A size
If Format_Select = "A Border" Then
ActiveSheet.ChangeSize("A", MoveBorderItems := True)
ActiveSheet.TitleBlock = "Small Border Title Block"
ActiveSheet.Border = "A-Border"

'Sets sheet size, title block, and border for B size Sheet 1
ElseIf Format_Select = "B Border Page 1" Then
ActiveSheet.ChangeSize("B", MoveBorderItems := True)
ActiveSheet.TitleBlock = "Large Format Page 1"
ActiveSheet.Border = "B thru F Border"

'Sets sheet size, title block, and border for B size Sheet 2+
ElseIf Format_Select = "B Border Page 2+" Then
ActiveSheet.ChangeSize("B", MoveBorderItems := True)
ActiveSheet.TitleBlock = "Large Format Page 2"
ActiveSheet.Border = "B thru F Border"

'Sets sheet size, title block, and border for C size Sheet 1+
ElseIf Format_Select = "C Border Page 1" Then
ActiveSheet.ChangeSize("C", MoveBorderItems := True)
ActiveSheet.TitleBlock = "Large Format Page 1"
ActiveSheet.Border = "B thru F Border"

'Sets sheet size, title block, and border for C size Sheet 2+
ElseIf Format_Select = "C Border Page 2+" Then
ActiveSheet.ChangeSize("C", MoveBorderItems := True)
ActiveSheet.TitleBlock = "Large Format Page 2"
ActiveSheet.Border = "B thru F Border"

'Sets sheet size, title block, and border for D size Sheet 1
ElseIf Format_Select = "D Border Page 1" Then
ActiveSheet.ChangeSize("D", MoveBorderItems := True)
ActiveSheet.TitleBlock = "Large Format Page 1"
ActiveSheet.Border = "B thru F Border"

'Sets sheet size, title block, and border for D size Sheet 2+
ElseIf Format_Select = "D Border Page 2+" Then
ActiveSheet.ChangeSize("D", MoveBorderItems := True)
ActiveSheet.TitleBlock = "Large Format Page 2"
ActiveSheet.Border = "B thru F Border"

'Sets sheet size, title block, and border for E size Sheet 1
ElseIf Format_Select = "E Border Page 1" Then
ActiveSheet.ChangeSize("E", MoveBorderItems := True)
ActiveSheet.TitleBlock = "Large Format Page 1"
ActiveSheet.Border = "B thru F Border"

'Sets sheet size, title block, and border for E size Sheet 2+
ElseIf Format_Select = "E Border Page 2+" Then
ActiveSheet.ChangeSize("E", MoveBorderItems := True)
ActiveSheet.TitleBlock = "Large Format Page 2"
ActiveSheet.Border = "B thru F Border"

'Sets sheet size, title block, and border for F size Sheet 1
ElseIf Format_Select = "F Border Page 1" Then
ActiveSheet.ChangeSize("F", MoveBorderItems := True)
ActiveSheet.TitleBlock = "Large Format Page 1"
ActiveSheet.Border = "B thru F Border"

''Sets sheet size, title block, and border for F size Sheet 2+
ElseIf Format_Select = "F Border Page 2+" Then
ActiveSheet.ChangeSize("F", MoveBorderItems := True)
ActiveSheet.TitleBlock = "Large Format Page 2"
ActiveSheet.Border = "B thru F Border"
End If


9 comments:

Paul Munford said...

Nice one Jon.

Jonathan Landeros said...

Thanks for the kind words, Paul! I'm glad the post was informative! :-)

Tomas said...

Hi! Really usefull function, thanks for posting. I now use this in a lot of drawings. I have a question you might know the anwer to: Can you use iLogic to define if the preconfigured drawings are in landscape or in portrait mode?

Jonathan Landeros said...

Tomas,

I'm not aware of a way to change a sheet to portrait or landscape, at least within iLogic.

It could likely be done through VB.NET, though.

One possible way to get there from here, would be to use the line for a custom sheet

ActiveSheet.ChangeSize(28.0, 20.0, MoveBorderItems := True)

This would let you adjust the sheet size to represent landscape or portrait.

Hope this helps!

Tomas said...

@Jonathan. I have tried this, but the thing is it dosen't matter if I write

(28.0, 20.0, MoveBorderItems := True) or
(20.0, 28.0, MoveBorderItems := True)
They orient in the same way. I still have to change to landscape/portrait in "Edit Sheet" to get the right orientation, which is strange i think. Am I doing something wrong?

Jonathan Landeros said...

@Tomas: I don't see anything you've done wrong. The function isn't working the way I thought.

The bad news is I'm a bit stumped. But I looked around a bit and found that Brian Hall took this exact routine and turbocharged it with VB.Net.

He's created a video here
http://www.youtube.com/watch?v=GvW6G5UZZJY&feature=player_embedded#at=24

The utilities can be downloaded here (you'll have to join the site, but it's free).

http://www.mcadforums.com/forums/viewtopic.php?f=34&t=11891

Hope this helps!

Tomas said...

Ok, I'll check my code again.

I'm using Brians turbocharged version as well, and sure, it's very quick to apply to new drawings. But I really like your version better becasue once you're done with the code it only takes one mouseclik to change sheetsize/boarder/title block etc.

Thanks for your halp!

Curtis Waguespack said...

Hi Jonathan and Thomas,
I've worked up a couple of example rules for changing the sheet orientation at this link:
http://inventortrenches.blogspot.com/2011/05/use-ilogic-to-change-sheet-orientation.html

Hope that helps,
Curtis

Jonathan Landeros said...

That looks really cool, Curtis. I'm going to have to check this one out!