- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have an iLogic rule to run on IPT's and some IAM's after the file saves to a STEP FILES folder.
The upper assemblies typically do not have the trigger set to save as a STEP file.
When in the context of an upper assembly, that does not have the trigger, and a save is done, the entire upper assembly is saved to a STEP file with the correct name of the lower level IPT/IAM that has a trigger. Unfortunately the STEP file contains the assembly not the individual part or respective assembly.
It works perfectly in the individual files but if I'm not careful, it overwrite the existing file with the assembly. Not good.
I think my problem, aside not knowing programming, is with the "Stepfilename = Thisdoc.path". Since I am in an upper assembly, it makes sense that would be the Thisdoc.path I'm in and not the individual file that has a trigger.
Stepfilename = ThisDoc.Path & "\STEP FILES\" & ThisDoc.FileName(False)
How do I get the rule to save each file, that has a trigger, to their respective file and path?
Hope this makes sense.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Yes, this is expected iLogic behaviour;
The iLogic functionality is really only intended for Active Document use and thus, if doing more complex operations, the programming should be switched over to vba or vb.net.
Take a look at the inventor programming help (that you can find through the question mark in the top right corner of the program) .
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Not being a programmer, can this be done?
If done in vba or vba.net, can it still be triggered?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
is required. More functionality is enabled though.
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks for the response.
Not being a programmer, what needs to change in the coding to get this to function as I would like?
Are there examples of coding or parts of other code that I could use?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
OK. Will do. Was hoping not to spend hours searching for it like I did with what I have.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Well, I have spent the last couple hours searching for something that could/would work to fix my code problem. No joy.
Probably there, but, I don't know the answer to my question to come up with the right keywords to use when searching.
A little help pointing me in the right direction would be most appreciated.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
API Help/Inventor forums:
ThisApplication.ActiveDocument.FullFileName
ThisApplication.Documents.Open("C:/Filenamehere.ipt, False)
google "msdn + ..... "
InStrRev
InStr
Len()
vb.net or vba introduction + subs and functions
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks again for the reply.
You seem to be a programmer or have a lot of experience with it and know how to do this. I am not a programmer and have no idea how to fix this or where to start. Searches are fine and I may stumble onto something that will work but don't have the time or inclination to become a programmer and start from scratch.
I'll change from asking for help to what would it cost to get it done?
Not trying to be antagonistic but I need to get this resolved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks for the reply.
Here is what I have. It works but needs the file check so it would export the correct file not the assembly it is in. Could just exit if not in the same file.
' Start of iLogic code ******************************************* 'query user question = MessageBox.Show("Is a STEP file needed for " & ThisDoc.FileName(False), "iLogic Question",MessageBoxButtons.YesNo,MessageBoxIcon.Question) 'set condition based on answer If question = vbNo Then Exit Sub End If 'check to see if in drawing If ThisApplication.ActiveDocumentType = DocumentTypeEnum.kDrawingDocumentObject Then doc = ThisApplication.ActiveDocument MsgBox("This iLogic rule will only run from a part or assembly", MsgBoxStyle.Exclamation, "Document Type Error") Exit Sub End If oPath=ThisDoc.Path oFolder = oPath & "\STEP FILES" 'Check to see if in same file or different'Is ThisDoc.FileName different from the Stepfilename needed?'if different, exit if same = then next 'Check for the STEP folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If 'Delete Files from folder containing this file name Dim path As String = ThisDoc.Path & "\STEP FILES\" For Each foundFile As String In My.Computer.FileSystem.GetFiles (path,Microsoft.VisualBasic.FileIO.SearchOption.SearchAllSubDirectories,"*" & ThisDoc.FileName(False) & "*") My.Computer.FileSystem.DeleteFile(foundFile) Next oRevNum = iProperties.Value("Project", "Revision Number") Stepfilename = ThisDoc.Path & "\STEP FILES\" & ThisDoc.FileName(False) Dim Sdate As String = DateString '& " " & TimeString CurrentFile = Stepfilename & " " & oRevNum & ".stp" ' Get the STEP translator Add-In. Dim oSTEPTranslator As TranslatorAddIn oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById _ ("{90AF7F40-0C01-11D5-8E83-0010B541CD80}") Dim oContext As TranslationContext oContext = ThisApplication.TransientObjects.CreateTranslationContext Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument _, oContext, oOptions) Then oOptions.Value("ApplicationProtocolType") = 3 oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism Dim oData As DataMedium oData = ThisApplication.TransientObjects.CreateDataMedium ' Set export name of STEP file oData.FileName = currentFile oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext _, oOptions, oData) End If ' End of export code *********************************************** ' Ask user if they want to open the export folder OpenFolder = MessageBox.Show("Export successful! " & _ "- open containing folder now?", "Save2STEP", _ MessageBoxButtons.YesNo, _ MessageBoxIcon.Question,MessageBoxDefaultButton.Button1) If OpenFolder = vbYes Then Process.Start("explorer.exe", ThisDoc.Path & "\STEP FILES\") Else ' User says continue 'Return End If ' End of iLogic code **************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
ie; Assembly 1 Folder\Assembly 1 parts
Assembly 1 Folder\Sub Assembly 1 Folder\ Sub Assembly Parts
I'm trying to figure out what the problem is from your first post..
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
There are instances where an assembly from the Common Parts folder is used on the different models of the product. They are not in a library like a switch or knob. If changed, it is for all model of the product. If they become unique, they get a new part number.
Product
Common Parts
Model 1
STEP Files
Model 2
STEP files
If I edit a part within the context of an assembly then finish edit without saving, then change something in the assembly and do a save, the standard dialog comes up asking if I want to save both files.
I click ok and both files are saved. The sub part which has the trigger to save as STEP when saved, gets run, which is fine but it saves the part with all the parts of the assembly not that part itself.
Inventor sees the assembly as the basis for the STEP file not the part being triggered and creates the STEP file with the correct name of the triggered file but with all the assembly parts.
Hope this makes sense.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@phila wrote:There are instances where an assembly from the Common Parts folder is used on the different models of the product. They are not in a library like a switch or knob. If changed, it is for all model of the product. If they become unique, they get a new part number.
Product
Common Parts
Model 1
STEP Files
Model 2
STEP files
If I edit a part within the context of an assembly then finish edit without saving, then change something in the assembly and do a save, the standard dialog comes up asking if I want to save both files.
I click ok and both files are saved. The sub part which has the trigger to save as STEP when saved, gets run, which is fine but it saves the part with all the parts of the assembly not that part itself.
Inventor sees the assembly as the basis for the STEP file not the part being triggered and creates the STEP file with the correct name of the triggered file but with all the assembly parts.
Hope this makes sense.
So you want it to save both files from the assembly if you editted a part in place, and not only that but to asave it down to step and overwrite the old version in the appropriate folder?
Also, has the program also created a STEP folder in the wrong location, and do you specifically want the old versions to be deleted forever, or would you rather have them go to the recycle bin?
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The way it is working it saves both files then creates the step file of the triggered file. The assembly does not have a trigger. Only want STEP files created on triggered files
If it can be done, yes, save the triggered part to the appropriate STEP FILES folder even if it is not in the same folder as the assembly being worked on.
It has not created a folder in the wrong place.
Delete is fine..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have been looking at this some more. It seems everything works as it should until the last line where the file is created.
oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext _, oOptions, oData)
At this point the translator is using ActiveDocument as the basis.
Is there a way to have it use the document with the trigger instead?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So if you were to put a messagebox right after CurrentFile
ie; MsgBox(CurrentFile)
it displays the correct filename for what you want the file to be?
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I added this to the top of the rule. I added it after posting the original rule:
' Start of iLogic code *******************************************
'query user
question = MessageBox.Show("Is a STEP file needed for " & ThisDoc.FileName(False), "iLogic Question",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
'set condition based on answer
If question = vbNo Then
Exit Sub
End If
This gives me the option to say no if I am in an assembly that does not have a trigger. Just have to remember what assembly I'm in.
The two parts that are this assembly have triggers to create a step file of each individual part. The assembly it self does not have a trigger. No STEP needed.
Each file with triggers opens the dialog box with their respective part numbers. Good to this point
If I click no, the rule stops, no STEP created. The second box opens, click no again.
If I click yes to both or just one, it creates the STEP file with the entire assembly with the respective file names in the dialog boxes. Both parts and all the hardware.
When I open either STEP file created, it is of the entire assembly not the single part.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
If I understand you correctly, you'll just have to iterate through the parts in the assembly and save them to STEP.
Here is a blog post on assemblies and components. In your case you'd just have to iterate through all the referenced part documents of the assembly: oAsmDoc.AllReferencedDocuments
http://modthemachine.typepad.com/my_weblog/2009/03/accessing-assembly-components.html
Cheers,

Adam Nagy
Autodesk Platform Services