open unsaved file on its own.

open unsaved file on its own.

Anonymous
Not applicable
572 Views
11 Replies
Message 1 of 12

open unsaved file on its own.

Anonymous
Not applicable

Hello

 

I have an IAM that contains various IPT parts. i would need to open them on their own, in a separate window. 

 

This part already works and is automatically called on save.

 

 

SyntaxEditor Code Snippet

ThisApplication.Documents.Open(part.FullFileName, True)

 

it works, but there is a problem with files that have been newely drawed and have not been saved yet. Not saved files are beeing written to disk just after this code, so the file does not exist yet and fullfilename returns a runtime error. 

 

How can the part be opened without the full file name? just as if i would right click -> open on the unsaved part?

 

thanks!

0 Likes
573 Views
11 Replies
Replies (11)
Message 2 of 12

MechMachineMan
Advisor
Advisor

Assign the file a file name before trying to run your code on it Smiley LOL


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

Anonymous
Not applicable

Are you saying something along the lines of "save it before you save it"? 😄

 

the code is run on save, and thats the reason for the problem.. can it be named without saving it?

 

0 Likes
Message 4 of 12

MechMachineMan
Advisor
Advisor

No, but you can cause your code that runs on save to "skip" the file if it doesn't have a name/hasn't been saved. You can also add in code to make the user name the file "on save".


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

Anonymous
Not applicable

my script verifies that certain Iproperties are filled in. if not, it opens up the file separately (to know what file needs to be tagged) and displays an input box for the tags. saving without those informations is what we want to avoid. so before we open the input box we open the IPT so you see it just behind the input box window and know what file you are tagging. Oroblem is I do not seem to be able to open a file from an assembly before it has been saved..

0 Likes
Message 6 of 12

MechMachineMan
Advisor
Advisor

The thing about the file names is that they are what is used to ID the part, so no file name = No ID.

 

If you want to find the part, you still can through the Documents enum, it's just that you have to establish what way you know it's the proper part without actually saving it.

 

Alternatively, you can ASSIGN the value to the .Fullfilename property without saving the document, so that you can access it in the future.

 

oDoc.FullFileName = TempName


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

Anonymous
Not applicable

thank you, will try it ASAP. So when you rightclick and open the unsaved part from an assembly it does it via the Documents enum?

0 Likes
Message 8 of 12

MechMachineMan
Advisor
Advisor

No, but by clicking on the file, you are providing the program with an identifying attribute of the file which you wish to use....


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

Anonymous
Not applicable

ok, not doubting about your knowlege here, since its vastly bigger than mine, just trying to understand: 

 

when the script is launched i get a reference to the Document i want to open. 

 

SyntaxEditor Code Snippet

Dim odoc As Document = ThisDoc.Document

 

 

its simply that i cannot open it, because

oDoc.FullFileName

 is empty.

 

Isnt there a way to say oDoc.open? or something like that? cant that oDoc be used as identifier just like the click in the window?

 

today I am going to try the sugestion you had to assign a temporary name to the ipt.

0 Likes
Message 10 of 12

MechMachineMan
Advisor
Advisor

Yes, that oDoc = ThisDoc.Document should grab a reference to the unnamed file as well, so that you can changed iproperties and such.

 

http://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html

 

Dim oDoc As Document
oDoc = ThisDoc.Document

oPN = oDoc.PropertySets("Design Tracking Properties")("Part Number").Value

MsgBox(oPN) 

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

Anonymous
Not applicable

The problem is not changing iproperties.. that is working fine already.. the problem is beeing able to open the ipt on its own, in a new window...

 

Document.open requires a path to a file... 

0 Likes
Message 12 of 12

marcin_otręba
Advisor
Advisor

try this:

 

Sub bnm()
On Error Resume Next
Dim odoc As AssemblyDocument
Set odoc = ThisApplication.ActiveDocument
Dim doc As Document
For Each doc In odoc.AllReferencedDocuments
Dim name As String
name = ""
name = doc.FullFileName
If name = "" Then
doc.Views.Add
End If
Next
End Sub

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders