.AddTitleBlock Help

.AddTitleBlock Help

MechMachineMan
Advisor Advisor
714 Views
4 Replies
Message 1 of 5

.AddTitleBlock Help

MechMachineMan
Advisor
Advisor

Hi there,

 

I've been trying to make a program that will go thorugh an idw and seperate out each sheet, moving it to a new .idw and changing the titleblock in the process. However, every time I try, it is giving me an error. 

 

I have made a similiar program to this, that essentially does the same thing, however it does not give me errors.

 

Is anyone aware of any hidden conditions involved in using the .AddTitleBlock method that is not mentioned in the API programming, or even what the .LateGet error is caused by?

 

Any help is much appreciated!

 

The error codes I get are:

 

Error in rule: oMakeDwg, in document: 334308-001 to 012.idw

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

------------------------------------------------------
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
   at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
   at LmiRuleScript.Main()
   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
   at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

Sub Main()

        Dim oSheet As Sheet = ThisApplication.ActiveDocument.Sheets.Item(ThisApplication.ActiveDocument.Sheets.Count)

        Dim sPromptStrings(4) As String
Try
        sPromptStrings(0) = oSheet.TitleBlock.GetResultText(oSheet.TitleBlock.Definition.Sketch.TextBoxes.Item(48)) ' Title
        sPromptStrings(1) = oSheet.TitleBlock.GetResultText(oSheet.TitleBlock.Definition.Sketch.TextBoxes.Item(49)) 'DESCRIPTION 1
        sPromptStrings(2) = oSheet.TitleBlock.GetResultText(oSheet.TitleBlock.Definition.Sketch.TextBoxes.Item(50)) 'DESCRIPTION 2
        sPromptStrings(3) = oSheet.TitleBlock.GetResultText(oSheet.TitleBlock.Definition.Sketch.TextBoxes.Item(52)) 'CUSTOMER DRAWING#
        sPromptStrings(4) = oSheet.TitleBlock.GetResultText(oSheet.TitleBlock.Definition.Sketch.TextBoxes.Item(53)) 'SCALE
        
        'oRevOrigin = oSheet.RevisionTables.Item(1).Position()
Catch
End Try
        
        oFileDoc=ThisApplication.Documents.Add(kDrawingDocumentObject,"C:\Users\ \Template File Containing New TitleBlock.idw", True)

        oSheet.CopyTo(oFileDoc)
        oFileDoc.Activate
        oFileDoc.Sheets.Item(oFileDoc.Sheets.Count).Activate

        oFile = "C:\Directory\" & "Test" & ".idw"
		‘Test is to be replaced by an iProperty once I get this                  		working

        oFileDoc.SaveAs(oFile, False)

        If Not oFileDoc.ActiveSheet.TitleBlock Is Nothing Then
              oFileDoc.ActiveSheet.TitleBlock.Delete
        End If
    
        Dim oTitleBlock As Inventor.TitleBlock
        oTitleBlock = oFileDoc.Sheets.Item(oFileDoc.Sheets.Count).AddTitleBlock("NEW TITLEBLOCK", ,sPromptStrings)

        oFileDoc.Sheets.Item(1).Delete
'        oFileDoc.Close
End Sub

 

 


--------------------------------------
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
0 Likes
Accepted solutions (1)
715 Views
4 Replies
Replies (4)
Message 2 of 5

MechMachineMan
Advisor
Advisor

Anyone out there?


--------------------------------------
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
0 Likes
Message 3 of 5

Anonymous
Not applicable
Could you attach your idw files that caused this error? There were many cases so I (and other members) couldn't know what exactly happened.
0 Likes
Message 4 of 5

MechMachineMan
Advisor
Advisor

Hi.

 

So I went through the IDW and removed the data specific to our company, and added in the code I was using to test it.

 

HOWEVER, now everything is working perfectly. So this is quite odd.

 

(There are 3 different titleblocks, and a drawing document)


--------------------------------------
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
0 Likes
Message 5 of 5

MechMachineMan
Advisor
Advisor
Accepted solution

Turns out it was an issue with a .LateGet Error.

 

Either way, the fix was simply to make a new sub function to add the titleblock.

 

The .AddTitleBlockFunctionality worked itself, however, when I tried to add a new document, then change titleblocks in that new document it got stumped.

 

I think there is something wrong with my defintion of oFileDoc.


--------------------------------------
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
0 Likes