10-06-2015
01:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-06-2015
01:30 AM
How to use this ThisDoc.Document in vb.net
Hey
Im trying to make my frist add-in that have to run, when i save *.ipt.
It works when I save .ipt file as active document.
But when I save the .ipt file from .idw and .iam, the add-in is not runing.
In iLogic I can solve it by using oDoc = ThisDoc.Document, but how does it work in vb.net?
10-06-2015
01:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-06-2015
01:41 AM
Hi, this could do it:
Dim oDoc As Document oDoc = ThisApplication.ActiveDocument
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
10-06-2015
06:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-06-2015
06:40 AM
Sorry but I can not translate that to my code.. ![]()
This code work when I save the part, but i´t wont run when I save the part from idw.
This code in modifyde from: Sheet Metal Extents Add-In
Private Sub m_appEvents_OnSaveDocument(ByVal DocumentObject As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_appEvents.OnSaveDocument
If BeforeOrAfter = EventTimingEnum.kBefore Then
Dim inventorAppType As Type = System.Type.GetTypeFromProgID("Inventor.Application")
Dim _InvApplication As Inventor.Application = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application"), Application)
Dim oPartDoc As PartDocument
oPartDoc = CType(_InvApplication.ActiveDocument, Inventor.PartDocument)
' Make sure the document is a sheet metal document.
If oPartDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
MsgBox("A sheet metal document must be open.")
Exit Sub
Else
MsgBox("A sheet metal has been save")
End If
End If
End Sub
10-06-2015
06:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-06-2015
06:49 AM
Yes, because you are trying to turn the idw into a part document, which will obviously throw an error
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
--------------------------------------
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
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
10-06-2015
11:45 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-06-2015
11:45 PM
Hi, you should work with the DocumentObject you get from the Sub instead of the ActiveDocument. Then your code also runs when you push the save button in an assembly. As it is right now you code only runs on the assembly itself and ignores its chldren (assumed you have an assembly open).