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: 

Drawing template configuration

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
kresh.bell
414 Views, 5 Replies

Drawing template configuration

Hi,

is it possible to make iLogic with which it was possible to choose the drawing template configuration? I would like to avoid several drawing templates files.
Eg, in drawing resources I have

- Title Block A,

- Title Block B,

- Title Block C.

 

When I run drawing, Inventor asks me what I want, "Approval or Production?". Or, if it is not possible the question "Approval or Production?" maybe something like "Do you want Approval drawing?" The answer "Yes" starts the Approval configuration, the answer "No" starts the Production configuration

 

Approval configuration is:
1st sheet Title Block A
2nd sheet Title Block B

 

Production configuration is:
1st sheet Title Block C
2nd sheet Title Block B

5 REPLIES 5
Message 2 of 6
Mathias_CompC
in reply to: kresh.bell

To answer your question, is it possible, yes.

If I wanted to set it up like that I would most likely use Sheet Formats and work from there.

Is there any particular reason you don't want to have two drawing templates, one named Approval, and the other Production?

Message 3 of 6
kresh.bell
in reply to: Mathias_CompC

I use a lot of common settings that I change relatively often, that's the reason why I'd rather have one template, if possible

Message 4 of 6
Mathias_CompC
in reply to: kresh.bell

Not sure what settings you'd "relatively often" change in a drawing template, perhaps the manual regarding Drawing Resource Transfer Wizard is of use? It really sounds like a hand-in-glove scenario to have two templates, but I'll follow this thread in case I'm completely off and there is something I could learn from it. 🙂

Message 5 of 6
JelteDeJong
in reply to: Mathias_CompC

This is how a rule would look like in its most basic form. If this would work for you, would depend on some factors.

In this example, I assumed that there is always a second sheet. Adding a new sheet is not that difficult but it would add more factors to consider. So the rule crashes if you do not have at least 2 sheets.

In this example, I also assumed that your title block does not have any prompted entries. That would also crash the script. fixing that would not be a big deal but would require knowledge of your title block setup.

There are probably some more edge cases that I did not think of. The point is that what you are asking is possible. but would potentially require a lot of tinkering. You might be better off with multiple templates or have a look into sheet format. It will let you add sheets to all the settings that you like.

Dim doc As DrawingDocument = ThisDoc.Document

Dim drawingTypes As New List(Of String)
drawingTypes.Add("Approval")
drawingTypes.Add("Production")

Dim selectedDrawingType = InputListBox("Select Type", drawingTypes, drawingTypes(0))

Dim titleBlockName1 = "Title Block A" ' Default title block for sheet 1
Dim titleBlockName2 = "Title Block B" ' Default title block for sheet1 2
If (selectedDrawingType = drawingTypes(0)) Then
    ' this code is triggerd if the 'Approval' configuration was selected
    titleBlockName1 = "Title Block A"
    titleBlockName2 = "Title Block B"

ElseIf (selectedDrawingType = drawingTypes(1)) Then
    ' this code is triggerd if the 'Production' configuration was selected
    titleBlockName1 = "Title Block C" 
    titleBlockName2 = "Title Block B"
End If

' Setup sheet 1
Dim sheet1 = doc.Sheets.Item(1)
If Not sheet1.TitleBlock Is Nothing Then
    sheet1.TitleBlock.Delete()
End If
sheet1.AddTitleBlock(doc.TitleBlockDefinitions.Item(titleBlockName1))

' Setup sheet 2
Dim sheet2 = doc.Sheets.Item(2)
If Not sheet2.TitleBlock Is Nothing Then
    sheet2.TitleBlock.Delete()
End If
sheet2.AddTitleBlock(doc.TitleBlockDefinitions.Item(titleBlockName1))

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 6 of 6
DeptaM
in reply to: kresh.bell

I use this rule and have it set to open when the drawing template is opened.

Dim drawingDoc as DrawingDocument = ThisDoc.Document

'A1 size
If Sheet_Size = "A1" Then
	ThisApplication.ActiveDocument.ActiveSheet.Orientation  = kLandscapePageOrientation
ActiveSheet.ChangeSize("A1", moveBorderItems := True)

'A2 size
ElseIf Sheet_Size = "A2" Then
	ThisApplication.ActiveDocument.ActiveSheet.Orientation  = kLandscapePageOrientation
ActiveSheet.ChangeSize("A2", moveBorderItems := True)

'A3 size
ElseIf Sheet_Size = "A3" Then
	ThisApplication.ActiveDocument.ActiveSheet.Orientation  = kLandscapePageOrientation
ActiveSheet.ChangeSize("A3", moveBorderItems := True)

'A4 size
ElseIf Sheet_Size = "A4" Then
	ThisApplication.ActiveDocument.ActiveSheet.Orientation  = kPortraitPageOrientation
ActiveSheet.ChangeSize("A4", moveBorderItems := True)



End If
'update all 
InventorVb.DocumentUpdate()
'zoom all
ThisApplication.ActiveView.Fit

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

Post to forums  

Autodesk Design & Make Report