William Pollard
***Edit 4-April-2012***
I've added the file I used in this blog post to the GrabCAD website if you want to download it and take a look. You do have to be a member, but I think you'll find that it's a great site with a lot of free CAD models.
***
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 |
Use event triggers to fire a rule when a particular event happens. This one occurs when you start a new file |
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
Nice one Jon.
ReplyDeleteThanks for the kind words, Paul! I'm glad the post was informative! :-)
ReplyDeleteHi! 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?
ReplyDeleteTomas,
ReplyDeleteI'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!
@Jonathan. I have tried this, but the thing is it dosen't matter if I write
ReplyDelete(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?
@Tomas: I don't see anything you've done wrong. The function isn't working the way I thought.
ReplyDeleteThe 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!
Ok, I'll check my code again.
ReplyDeleteI'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!
Hi Jonathan and Thomas,
ReplyDeleteI'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
That looks really cool, Curtis. I'm going to have to check this one out!
ReplyDeleteI've had an error pop up continuously and it was driving me mad.
ReplyDelete"The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"
I found out that the code won't handle title blocks with prompted entries as posted. You have to change the line:
ActiveSheet.TitleBlock = "Your_title_block_name" - to
ActiveSheet.SetTitleBlock("Your_title_block_name", "Prompt1", "Prompt2", "Prompt-n")
And then *poof* it works.
Pierre
Dr. Fleau,
DeleteThanks for the tip. I haven't done anything with prompted entries and iLogic (it's just not something I've tried), but I'll have to keep that in mind for when I do!
You have a done a great job man! I appreciate you and the clip is just awesome o easy understand. CAD software is a good thing and it will help you to design and order directly from your browser. Thanks and have a good day!
ReplyDelete