iLogic: Set open document as active

iLogic: Set open document as active

Anonymous
Not applicable
5,168 Views
12 Replies
Message 1 of 13

iLogic: Set open document as active

Anonymous
Not applicable

Hi everyone,

I had a rule that saves the ipt and open and saves the idw. Now i want to add some other things i would like to do on the drawing in the same rule, how do i set the open document (.idw) as active?

Thanks a lot for the help, I've found another question similar to mine but the solution isn't working for me.

0 Likes
5,169 Views
12 Replies
Replies (12)
Message 2 of 13

MechMachineMan
Advisor
Advisor

oDocToModify = oDoc.Open(Name, Boolean)

Recalling oDocToModify will let you access the doc you just opened.

 

Or.

 

oDocToModify = oDoc.ItemByName(DocumentName)


--------------------------------------
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 13

Anonymous
Not applicable

Thanks for your help, but it's not working, sorry but i'm kinda new to iLogic and VBA in general.

it says oDoc undecleared.

I open my file with:

 

ThisDoc.Launch("filename.idw") 

 

the idw is in the same directory as the main file from witch I start the rule.

It gives error also if I calcel the function and I execute only your solution.

Could you help me? thanks a lot in advance.  

 

0 Likes
Message 4 of 13

MechMachineMan
Advisor
Advisor
Dim oDoc2 Ad Document
oDoc2 = ThisApplication.Documents.Open("C:/IDWNAME.idw",True) 'Change path
as needed, true is visible

You need to use the FullFileName of the idw to open it with this method.

--------------------------------------
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 5 of 13

Anonymous
Not applicable

Ok the code is working and I can open the file, but it seems to be not active because if I add a funcion for idw it says filename is not a drawing I think I should set oDoc2 as active in some way...

0 Likes
Message 6 of 13

Anonymous
Not applicable

Now i'm using this code without success

 

Dim oDoc2 As Document
oDoc2 = ThisApplication.Documents.Open("T:\Inventor\PARAMETRICO\PERNO ILOGIC\PERNO.idw",True)
myfile=oDoc2.FileName
oDoc2.Saveas(myfile, False)

 

0 Likes
Message 7 of 13

MechMachineMan
Advisor
Advisor
Post a screen capture of what pops up in the error screen, both tabs.

--------------------------------------
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 8 of 13

Anonymous
Not applicable

This when i use the last code i posted.

in english:

Impossible to find pubblic member "FileName" in tipe "_DocumentClass"

0 Likes
Message 9 of 13

MechMachineMan
Advisor
Advisor

@Anonymous wrote:

This when i use the last code i posted.

in english:

Impossible to find pubblic member "FileName" in tipe "_DocumentClass"



Yes, so exactly as it says, the method "FileName" that you are trying to call is not a valid method for the class that you are trying to call it for.

 

You have oDoc.FileName... Well oDoc is an object of the Document class, and you are trying to call the method FileName from within it.

What that tells you is that the class has no clue what you are trying to tell it to do, because FileName is not a recognized command for it.

 

Whenever you see this error, just go look up in API help a similiar method that will accomplish what you need by search for the class first.

 

Open it up as shown in the window below, select the search tab and look up "Document".

 

Good luck.

api HELP.JPG


--------------------------------------
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 10 of 13

Anonymous
Not applicable

Thanks a lot, I can't find the help, probably because i have 2013 version. I'll try however to learn something!

0 Likes
Message 11 of 13

MechMachineMan
Advisor
Advisor
You should be able to find it manually if it came with one; try searching for a path like:

C:\Program Files\Autodesk\Inventor 2016\Local Help

It should be contained in the file named something like admapi_14_0.chm

--------------------------------------
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 12 of 13

Anonymous
Not applicable

Now i'm trying to understand someting, like you said, the comand has to be in the right place, ive download the API model and understood that, but what i cant understand now is: are there some other classical comand that arent listed in the API? Such ad open\load file exc?they are notlisted because are classical VBA comands and not inventor specifics?

0 Likes
Message 13 of 13

MechMachineMan
Advisor
Advisor

There are some things that aren't listed in API because they already exist in the VBA language; ie the use of operators such as LIKE and wildcards,

 

However, file operations such as Open and Save all exist under the document/documents object. There are other ways to access these too, such as through the FileManager object.


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