Copy form to other files

Copy form to other files

ChristianAndersenIsmyname
Advocate Advocate
1,187 Views
5 Replies
Message 1 of 6

Copy form to other files

ChristianAndersenIsmyname
Advocate
Advocate

Hi,

 

I've made a post here about updating template on all existing files with a new template. This new template has a bunch of iLogic rules and Form. Basically no changes to the standard template, only added iLogic features.

However, the response I got on that post was that this could possibly be done through writing a code with Inventor's API.

 

Through searching around, I've found code injector - a program that can add rules and event triggers to existing file(s). While this is better than nothing, I could really need to copy Forms as well.

 

Is it possible to write a code/script/something that copies Forms from one file to another?

Less than ideal solution would be to change internal forms to external forms I suppose.

 

Thank you for all your answers!

And thanks for all help I've got earlier with the rules I'm now ready to implement on all files.

0 Likes
1,188 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

Even though there is a pre-defined iLogic Object (Type) called "iLogicForm", there there isn't a way to set its value to a specific local form of the document, that I know of.  So, I'm thinking this may have to be done by the BrowserPane and BrowserNode objects, then using a regular Copy command.  Then open the second document (if not already open by your code at this point) and navigate to its iLogic BrowserPane and Forms tab, then use the Paste command.  This is just an idea at this point, but at least I know I can do this manually, so it is most likely doable by code too.  It's just not going to be 'as easy as it should be'.  I've navigated through browser panes and nodes plenty, so it shouldn't be too big of a job.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 6

ChristianAndersenIsmyname
Advocate
Advocate

Manually doing this would take too much time, so external forms is likely the solution for now. It won’t be as pretty or easy to navigate though, as it’s ~15 different forms.

 

I do agree though, if it’s possible to manually do it, why shouldn’t it be able to write something that do it for you.

But my knowledge about how Autodesk have coded their files or coding in general is very limited.

0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor

Actually, the iLogic tab is a DockableWindow instead of a BrowserPane, because I found it by searching within both collections, and only the DockableWindows contained one with that name.

This thing may still be doable by code.  If I'm not busy with other things, I'll continue to look into this.  Seems like something that could be very useful. 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 6

ChristianAndersenIsmyname
Advocate
Advocate

That would be amazing!

In my search for this code/function, I came across many posts asking for a feature like this.

I think many people will be happy if this is possible!

0 Likes
Message 6 of 6

WCrihfield
Mentor
Mentor

Well...even though I can get the iLogic DockableWindow, its Control property just returns Nothing, which means it must contain a 'dialog' instead of a regular Control.  I honestly don't know of a way to get that 'dialog' from this point.  I assume 'dialog' means a Windows Form.  I was hoping there was a way to use the HWND property of this DockableWindow to somehow find the 'Child' object (dialog) of this window using some sort of advanced vb.net code.  Unfortunately, if it can be done, I haven't been able to figure it out yet.

Hopefully, some of the others here on the forum (or some Autodesk Employees) can either figure out how, or find out if it's impossible, and let us know.

Here's what I've got, so far, which shows how to get that window.

Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oUIMgr As UserInterfaceManager = ThisApplication.UserInterfaceManager
Dim oILogicW As DockableWindow = oUIMgr.DockableWindows.Item("ilogic.treeeditor")
'oILogicW.Control is Nothiing so instead of a Control, it has a 'Dialog'
'I assume this means a Windows Form
'Attempt to get the Windows Form within using the HWND of the DockableWindow
Dim oHWND As Integer = oILogicW.HWND
'Dim oWinForm As Windows.Forms.Form
'Dim oTV As TreeView
'Dim oChildHWND As Integer = GetDlgCtrlID()

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)