Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Update idw Title Blocks from Template File with iLogic

18 REPLIES 18
Reply
Message 1 of 19
ccoomes
4913 Views, 18 Replies

Update idw Title Blocks from Template File with iLogic

I am trying to create an iLogic (or VB) rule to update an active drawing title blocks from our Template File.

 

Is this possible?

 

I don't want to use any of the external software (Transfer Wizard etc), we just need a simple rule that will update the title blocks when we need to.

 

Any help would be greatly appreciated.

18 REPLIES 18
Message 2 of 19
Cadmanto
in reply to: ccoomes

What exactly are you trying to update?  iProperties?

I am not following what you are trying to accomplish.

 

check.PNGIf this solved your issue please mark this posting "Accept as Solution".

Or if you like something that was said and it was helpful, Kudoskudos.PNG are appreciated. Thanks!!!! Smiley Very Happy

 

New EE Logo.PNG

Inventor.PNG     vault.PNG

Best Regards,
Scott McFadden
(Colossians 3:23-25)


Message 3 of 19
tsreagan
in reply to: ccoomes

This should be possible in iLogic.

 

You can get things from and insert things into a drawing with iLogic,  so as long as your templates do not move, then a rule should be able to pull updated items and params from them.

 

The time to develop the rule may outweigh using the task scheduler to automatically update files for you.

 

T.S.

 

 

 

Message 4 of 19
ccoomes
in reply to: Cadmanto

We are trying to update the Title Blocks in the Drawing Resources.

 

We currently do this by opening up the Template file, selecting the Title blocks in the drawing resources and copying them..

Then goping to the active docuemtn and pasting the new title blocks into the drawing resources and replace the old ones with the new ones.

 

Hope this makes sense?

 

Many thanks

Message 5 of 19
kwilson_design
in reply to: ccoomes

Use the Drawing Resource Transfer Wizard (Start menu -> Programs -> Autodesk -> Autodesk Inventor [version] -> Tools -> Drawing Resource Transfer Wizard).

 

It updates selected "target" drawings' Drawing Resource folders using your new template drawing as the "source" file. This is how I push a change in our drawing borders across all the files.

 

Read more here http://wikihelp.autodesk.com/Inventor/enu/2012/Help/0073-Autodesk73/0684-Collabor684/0725-Tools725/0...

Regards,
Kenny
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
Message 6 of 19
Cadmanto
in reply to: ccoomes

Yeah, that makes sense.  As you make changes to your titleblocks, you want to be able to grandfather those changes into drawings that have already used the old TB's through iLogic.

Yes, this should be able to be done.  I am not an iLogic guru, so I can't help you with that.  Sorry.

 

check.PNGIf this solved your issue please mark this posting "Accept as Solution".

Or if you like something that was said and it was helpful, Kudoskudos.PNG are appreciated. Thanks!!!! Smiley Very Happy

 

New EE Logo.PNG

Inventor.PNG     vault.PNG

Best Regards,
Scott McFadden
(Colossians 3:23-25)


Message 7 of 19
Rene-J
in reply to: ccoomes

Have you check this free addin.

Automatic update Drawing Resources

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

 

Rene J

Message 8 of 19
tsreagan
in reply to: ccoomes

"I don't want to use any of the external software (Transfer Wizard etc), we just need a simple rule that will update the title blocks when we need to."

 

I know you stated the above,  what is the main reasoning for this?

If it is time,  then the time it takes to update 1 drawing would be about the time it takes to wizard all the changes over to all the drawings.

 

Also I believe you can schedule updates to occur off-hours, if you are running a network that is always up.

 

T.S.

 

Message 9 of 19
kwilson_design
in reply to: tsreagan

Yea I'm not understanding the reasoning for the OP not wanting to use the Wizard as it saves a ton of time. The DRTW is also not what I would consider "External Software" since it runs IV in the background when you use the utility.

 

Rene, never knew of that free add-in. I have always wanted to make my template become a true "master file" for which all changes would populate to drawings down the road. I will have to give that add-in a try! Thanks for posting it.

Regards,
Kenny
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
Message 10 of 19
Cadmanto
in reply to: tsreagan

In this thread link I believe there is a rule that might do what you are looking to do.

Check it out.

http://forums.autodesk.com/t5/Autodesk-Inventor/iLogic-help-needed/td-p/3556718

 

check.PNGIf this solved your issue please mark this posting "Accept as Solution".

Or if you like something that was said and it was helpful, Kudoskudos.PNG are appreciated. Thanks!!!! Smiley Very Happy

 

New EE Logo.PNG

Inventor.PNG     vault.PNG

Best Regards,
Scott McFadden
(Colossians 3:23-25)


Message 11 of 19
ccoomes
in reply to: Cadmanto

Thanks to all for your comments.

 

As per my original thread, we have no interest in using the drawing transfer wizard.  Yes, it may be good at what it does, but we don't want to use it.

 

All we want to be able to do is update our title blocks (From our Template File - This does not move) from a simple click in Inventor using I logic.

 

Ref the Add-in, we don't want to use this as it would mean installing it on each machine and then setting it up.

 

Thank you for posting the links to the threads about updating the title blocks.  I have already tried these and they work, but just for the active sheet not the whole drawing.

 

We need to be able to update ALL the title blocks in the Drawing, not the Active Sheet.

When you manually paste the title blocks into the Drawing Resources it updates all the sheets.

 

Thanks again you for support and any other assistance would be great.

Message 12 of 19
pball
in reply to: ccoomes

I have some normal VBA code which will copy and replace a titleblock from a template file. I'm not familar with iLogic but you should be able to use this as a base or for ideas.

 

This function is made to replace a specific assembly or detail title block but could be changed to be more general.

Function Uptitle()
    Dim odrawdoc As DrawingDocument
    Dim oTemplate As DrawingDocument
    Dim oSourceTitleBlockDef As TitleBlockDefinition
    Dim oNewTitleBlockDef As TitleBlockDefinition
    Dim oSheet As Sheet

    Set odrawdoc = ThisApplication.ActiveDocument
    Set oSheet = odrawdoc.ActiveSheet
    
    If (oSheet.TitleBlock.name = "DPMS_ASSY") Then
        fname = "D_ASSY.idw"
    ElseIf (oSheet.TitleBlock.name = "TOLERANCE") Then
        fname = "D_DET.idw"
    Else:
        MsgBox "This drawing has an unknown title block"
        Exit Function
    End If
    
    Set oTemplate = ThisApplication.Documents.Open(ThisApplication.FileOptions.TemplatesPath & fname, False)
    Set oSourceTitleBlockDef = oTemplate.ActiveSheet.TitleBlock.Definition
    Set oNewTitleBlockDef = oSourceTitleBlockDef.CopyTo(odrawdoc, True)
    
    On Error GoTo ErrHandler:
    For Each oSheet In odrawdoc.Sheets
        'oSheet.Activate if error occurs
        oSheet.TitleBlock.Delete
        Call oSheet.AddTitleBlock(oNewTitleBlockDef)
    Next
    oTemplate.Close
    
    Exit Function
ErrHandler:
    oSheet.Activate
    Resume
End Function

 

Message 13 of 19
ccoomes
in reply to: pball

Thank you to all who have posted and helped with this issue.

 

Sorry it has taken me so long to get back with our solution..

 

Attached is the code I have managed to get to work (with a single click of a button on an Inventor iLogic Form) to update the title blocks in a drawing from our drawing template.

 

This is the basic process of the code:

 

Remember the Active Sheet Name & the Title Block visible.

Delete ALL the Title Blocks from each and every sheet.

Delete the Title Blocks from the Drawing Resources

Get the Title Blocks from the Template File

Insert the Title Block that was on the active sheet on all the sheets.

Re-Select the Active sheet at the start of the code.

 

The things I have found out as I have been doing it as as follows:

 

The Names of Each Title Block MUST be the Same for the Template File and the Files being inserted into.

This is to ensure that the title block on the active sheet when the button is plressed is inserted into the drawing at the end.

I used the full path for our template file and NOT referanced a Drive Letter.

The Screen flickers alot when this is being updated as the Code activates each sheet.

If you run this code from a rule or a NON-Modial Form, it will expand every sheet in the browser to show the Title Block Being inserted.

However, If you run the rule from a button on a Modial Form, it will not modify the expanded sheets in the browser.

 

I know this is not a very pretty bit of code, but it works for us and is a single click to update the title blocks as and when we need to.

 

If anyone has any comment or improvements on the code (Getting rid of the screen flickering would be great) plesae let me know.

 

Thanks again.

 

Clive.

Message 14 of 19
sco.smith
in reply to: ccoomes

This is exactly what I am looking for with one small caveat. IN order for it to work, I have to manually delete all sheet formats using those titleblocks first.

 

Does anyone have a fragment of iLogic code that will delete all sheet formats so that I can append this one?

 

Thanks in advance,

 

Scott

Message 15 of 19
MechMachineMan
in reply to: ccoomes

ThisApplication.ScreenUpdating = False

ThisApplication.ScreenUpdating = True

Add error checking to reset the screen updating to true in case the program encounters an error.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 16 of 19

Hi sco.smith,

 

Here is a bit of code taken from my own custom Replace Title Block From Template rule. I think it should work for you, but I didn't test it, I just copy/pasted from what I had. Post back it doesn't work and I'll have a look to see what I left out/inlcluded, that is needed/not needed.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

If oCurrentPane = "Vault" Then
ThisApplication.ActiveDocument.BrowserPanes.Item("Model").Activate
End If
	
	'delete sheet formats
	Dim oDoc As DrawingDocument
	oDoc = ThisApplication.ActiveEditDocument
	
	Dim oPane As BrowserPane
	oPane = oDoc.BrowserPanes.ActivePane
	
	Dim oDocNode As BrowserNode
	oDocNode = oPane.TopNode
	
	Dim oDrawingResourceNode As BrowserNode
	oDrawingResourceNode = oDocNode.BrowserNodes.Item("Drawing Resources")
	
	
	Dim oSheetFormatsNode As BrowserNode
	oSheetFormatsNode = oDrawingResourceNode.BrowserNodes.Item("Sheet Formats")
	
	Dim oNode As BrowserNode 
	For Each oNode In oSheetFormatsNode.BrowserNodes'oDocNode.BrowserNodes
	' If the node is visible and expanded, collapse it.
	If oNode.Visible = True And oNode.Expanded = False Then
	oNode.Expanded = True
	End If
	Next
	
	Dim oSheetFormatNode As BrowserNode
	For Each oSheetFormatNode In oSheetFormatsNode.BrowserNodes
	' Select the node in the browser.
	oSheetFormatNode.DoSelect
	
	' Execute the delete command.
	ThisApplication.CommandManager.ControlDefinitions.Item("AppDeleteCmd").Execute
	Next
Message 17 of 19

Thank you so much, Curtis. As always, you are a god.

 

Scott

Message 18 of 19
Joel.Manrique
in reply to: ccoomes

This works great, but my issue is that I have the same name for title block. 

 

I think what I'm looking for is to replace.  is there a code for that?

 

and I also like to replace the border. 

 

Thanks,

Joel

Message 19 of 19
Jason_Hunt
in reply to: Joel.Manrique

Here is my code I use:

 

Here is the main rule "Drawing Border and Title Block Update". I will also include the following External rules used in the code.

- "New Border Rule"

- "Border Deletion

 

 

 

 

SyntaxEditor Code Snippet

Sub Main()
iLogicVb.RunExternalRule("NEW BORDER RULE")
ActiveSheet = ThisDrawing.Sheet("Sheet:1")
Dim N As Integer                                        'TOTAL NUMBER OF SHEETS
Dim X As Integer                                        'SHEET NUMBER USED FOR DO LOOP COUNTER

'---------------------COUNT THE TOTAL NUMBER OF SHEETS
Dim oDrawing As DrawingDocument
oDrawing = ThisApplication.ActiveDocument
Dim osheet As Sheet
i = 0
For Each osheet In oDrawing.Sheets
If osheet.ExcludeFromCount = True Then
i = i + 1
Else
End If
Next
'---------------------REMOVE EXCLUDED SHEET FROM THE TOTAL SHEET COUNT
oMySheetCount = oDrawing.Sheets.Count - i
N = oMySheetCount
X = 1
'---------------------REMOVE THE EXCLUDED SHEET FROM THE TOTAL SHEET COUNT
oMySheetCount = oDrawing.Sheets.Count - i
N = oMySheetCount
X = 2

'Check if the document is drawing
If ThisApplication.ActiveDocument Is Nothing Or ThisApplication.ActiveDocumentType <> kDrawingDocumentObject Then
    MsgBox ("Please open a Drawing to work on.")
    Exit Sub
End If

    Dim oDrawingDoc As Inventor.DrawingDocument: oDrawingDoc = ThisApplication.ActiveDocument
    Dim SheetNumber As Integer
    
    'TITLEBLOCK
    result = MessageBox.Show("Do You wish to Insert new Title block?", "Insert Title block", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If result = "6" Then
            'Clear out the old Titleblocks
            For SheetNumber = 1 To 1
                ActiveSheet = ThisDrawing.Sheet("Sheet:1") 
                If Not oDrawingDoc.ActiveSheet.TitleBlock Is Nothing Then
                oDrawingDoc.ActiveSheet.TitleBlock.Delete
                End If
            Next
            
'            ActiveSheet = ThisDrawing.Sheet("Sheet") '            If Not oDrawingDoc.ActiveSheet.TitleBlock Is Nothing Then'            oDrawingDoc.ActiveSheet.TitleBlock.Delete'            End If
            
            'Delete the previous title blocks as the API does not support replacing Sheet Formats.
            DeleteTitleBlocks (oDrawingDoc) 'CALLING SUBROUTINE
        
            'reference template
            ThisDrawing.ResourceFileName = "\\FSE-VAULTEX\FSE-Standards\Templates\Test Area - Do Not Use\FSE.dwg"
            ThisDrawing.KeepExtraResources = False
            
               ActiveSheet = ThisDrawing.Sheet("Sheet:1") 
            ActiveSheet.TitleBlock = "FSE PRIMARY"

        End If

'---------------------DO LOOP TO CHANGE SHEETS 2 AND ABOVE
If N > 1 Then

    Do While X <= N
    
        ActiveSheet = ThisDrawing.Sheet("Sheet:"&X)
        ActiveSheet.TitleBlock = "FSE SECONDARY"
    X = X+1    
    Loop
    

End If

X = 2
N = oMySheetCount
ActiveSheet = ThisDrawing.Sheet("Sheet:1")
'---------------------ZOOM ALL
ThisApplication.ActiveView.Fit
'---------------------UPDATE ALL
RuleParametersOutput()
InventorVb.DocumentUpdate()

End Sub

'subroutine
Sub DeleteTitleBlocks(oActiveDoc As Inventor.DrawingDocument)
'Iterate through the collection deleting any titleblocks that are not referenced by the drawing object
Dim oTitle As TitleBlockDefinition
    For Each oTitle In oActiveDoc.TitleBlockDefinitions
        If oTitle.IsReferenced = False Then
        oTitle.Delete
        End If
    Next
End Sub


"New Border rule"

SyntaxEditor Code Snippet
resu1t = MessageBox.Show("Do You wish to replace the borders?", "Replace Borders", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    If resu1t = "6" Then
    
        Dim N As Integer                                        'TOTAL NUMBER OF SHEETS
        Dim X As Integer                                        'SHEET NUMBER USED FOR DO LOOP COUNTER
        
        '---------------------COUNT THE TOTAL NUMBER OF SHEETS
        Dim oDrawing As DrawingDocument
        oDrawing = ThisApplication.ActiveDocument
        Dim osheet As Sheet
        i = 0
        For Each osheet In oDrawing.Sheets
        If osheet.ExcludeFromCount = True Then
        i = i + 1
        Else
        End If
        Next
        '---------------------REMOVE EXCLUDED SHEET FROM THE TOTAL SHEET COUNT
        oMySheetCount = oDrawing.Sheets.Count - i
        N = oMySheetCount
        X = 1
            Do While X <= N
                ActiveSheet = ThisDrawing.Sheet("Sheet:"&X)
        '-------------THIS RULE DELETES THE SHEET BORDER ON THE ACTIVE SHEET
                iLogicVb.RunExternalRule("BORDER DELETION")
                
            X = X+1    
            Loop

        
        X = 1
    
        ThisDrawing.ResourceFileName = "\\FSE-VAULTEX\FSE-Standards\Templates\Test Area - Do Not Use\FSE.dwg"
        ThisDrawing.KeepExtraResources = True
        ActiveSheet.Border = "FSE - A1"
        ActiveSheet.Border = "FSE - A0"
        iLogicVb.RunExternalRule("BORDER DELETION")
    End If
    


ActiveSheet = ThisDrawing.Sheet("Sheet:1")
'---------------------ZOOM ALL
ThisApplication.ActiveView.Fit
'---------------------UPDATE ALL
iLogicVb.RunExternalRule("iProperties - Drawing")
RuleParametersOutput()
InventorVb.DocumentUpdate()
ThisDoc.Save


"Border Deletion Rule"

SyntaxEditor Code Snippet
'-------------THIS RULE DELETES THE SHEET BORDER ON THE ACTIVE SHEET
Dim oDrawDocC As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheetC As Sheet = oDrawDocC.ActiveSheet
Dim oBorderC As Border = oSheetC.Border
oBorderC.Delete

 


Did you find this reply helpful? If so, please use the Accept as Solution or use the Kudos button below.

Best Regards,

Jason Hunt

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

Post to forums  

Autodesk Design & Make Report