- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello to all. I have working iLogic code that exports sheet metal flat patterns to a dwg file with the correct options needed by the programming team. We have code elsewhere that works great with normal parts to automate the exporting process.
Here's the code as of now:
SyntaxEditor Code Snippet
Dim oDoc As PartDocument oDoc=ThisApplication.ActiveDocument Dim oCompDef As SheetMetalComponentDefinition oCompDef=oDoc.ComponentDefinition Dim oDataIO As DataIO oDataIO=oDoc.ComponentDefinition.DataIO If oCompDef.HasFlatPattern=False Then oCompDef.Unfold Else oCompDef.FlatPattern.Edit End If Dim sOut As String sOut="FLAT PATTERN DWG?AcadVersion=2000" _ +"&InvisibleLayers=IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL" _ +"&SimplifySplines=True" _ +"&LINEAR TOLERANCE=0.010" _ +"&MergeProfilesIntoPolyline=True" _ +"&RebaseGeometry=False" _ +"&TrimCenterlines=True" Dim sFname As String sFname=oDoc.FullFileName sFname=Left$(sFname,Len(sFname)-3)&"dwg" oCompDef.DataIO.WriteDataToFile(sOut,sFname)
The problem is when it exports a flat pattern from an iPart file it, of course, reads the file name such as "PANELS" instead of the iProperties Part Number such as "ST9".
How do I change the code so that it saves the dwg file with the name from the Part Number instead of the File Name?
I've tried simply changing the code to this:
SyntaxEditor Code Snippet
Dim oDoc As PartDocument oDoc=ThisApplication.ActiveDocument Dim oCompDef As SheetMetalComponentDefinition oCompDef=oDoc.ComponentDefinition Dim oDataIO As DataIO oDataIO=oDoc.ComponentDefinition.DataIO If oCompDef.HasFlatPattern=False Then oCompDef.Unfold Else oCompDef.FlatPattern.Edit End If Dim sOut As String sOut="FLAT PATTERN DWG?AcadVersion=2000" _ +"&InvisibleLayers=IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL" _ +"&SimplifySplines=True" _ +"&LINEAR TOLERANCE=0.010" _ +"&MergeProfilesIntoPolyline=True" _ +"&RebaseGeometry=False" _ +"&TrimCenterlines=True" Dim sFname As String sFname=iProperties.Value("Project", "Part Number")&".dwg" oCompDef.DataIO.WriteDataToFile(sOut,sFname)
But all I get is the typical HRESULT fail code which doesn't tell me anything. I've also tried using the Convert to String code like below:
SyntaxEditor Code Snippet
sFname=CStr(iProperties.Value("Project", "Part Number"))&".dwg"
But that doesn't work either, if I can get a solution on this that would save the step of having to rename each export one at a time, that would be awesome.
My second request would be to add code to automatically do these steps for every member in the iPart table instead having to run the code, change the iPart member, then run the code again for every member.
Thanks so much in advance, I've learned plenty about iLogic in the past few months, it's just the little details here and there that trip me up.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Likely what you need to do is access the document's component definition, check isiPartmember, then iterate through the rows using the available function calls. You will be able to use the changerow call to swap through each iPart, and use the .Row property to grab the part number for that item.
http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-FE230CC1-D9A7-4050-9018-2BBE35941067
or it might be the same, but using the iPart factory things. Not too familiar with anything else, but you should be able to find some samples within the programming help resources.
--------------------------------------
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 is a code sample that's supposed to get the value Part Number:
SyntaxEditor Code Snippet
Public Sub GetPropertySample() ' Get the active document. Dim invDoc As Document Set invDoc = ThisApplication.ActiveDocument ' Get the design tracking property set. Dim invDesignInfo As PropertySet Set invDesignInfo = invDoc.PropertySets.Item("Design Tracking Properties") ' Get the part number property. Dim invPartNumberProperty As Property Set invPartNumberProperty = invDesignInfo.Item("Part Number") MsgBox "Part Number: " & invPartNumberProperty.Value End Sub
I tried to put it in my code below:
SyntaxEditor Code Snippet
Dim oDoc As PartDocument oDoc=ThisApplication.ActiveDocument Dim oCompDef As SheetMetalComponentDefinition oCompDef=oDoc.ComponentDefinition Dim oDataIO As DataIO oDataIO=oDoc.ComponentDefinition.DataIO If oCompDef.HasFlatPattern=False Then oCompDef.Unfold Else oCompDef.FlatPattern.Edit End If Dim sOut As String sOut="FLAT PATTERN DWG?AcadVersion=2000" _ +"&InvisibleLayers=IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL" _ +"&SimplifySplines=True" _ +"&LINEAR TOLERANCE=0.010" _ +"&MergeProfilesIntoPolyline=True" _ +"&RebaseGeometry=False" _ +"&TrimCenterlines=True" Dim invDesignInfo As PropertySet invDesignInfo=oDoc.PropertySets.Item("Design Tracking Properties") Dim invPartNumberProperty As Property invPartNumberProperty=invDesignInfo.Item("Part Number") Dim sFname As String sFname=invPartNumberProperty & ".dwg" oCompDef.DataIO.WriteDataToFile(sOut,sFname)
But I get an error on Line 22 (Dim invPartNumberProperty As Property) that says:
Keyword does not name a type.
I am lost on what this means. I also noticed that when I type in "Property" it turns red and begins an outline ticker, is that what's causing the Keyword error? Am I supposed to close this with a "End Property" line or something. It honestly should not be this difficult to get the Part Number into an object or string so I can use it as the file name when I export the dwg.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dim oDoc As PartDocument
oDoc=ThisApplication.ActiveDocument
Dim oCompDef As SheetMetalComponentDefinition
oCompDef=oDoc.ComponentDefinition
Dim oDataIO As DataIO
oDataIO=oDoc.ComponentDefinition.DataIO
If oCompDef.HasFlatPattern=False Then
oCompDef.Unfold
Else
oCompDef.FlatPattern.Edit
End If
Dim sOut As String
sOut="FLAT PATTERN DWG?AcadVersion=2000" _
+"&InvisibleLayers=IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL" _
+"&SimplifySplines=True" _
+"&LINEAR TOLERANCE=0.010" _
+"&MergeProfilesIntoPolyline=True" _
+"&RebaseGeometry=False" _
+"&TrimCenterlines=True"
Dim invDesignInfo As PropertySet
invDesignInfo=oDoc.PropertySets.Item("Design Tracking Properties")
Dim invPartNumberProperty As Inventor.Property
invPartNumberProperty=invDesignInfo.Item("Part Number")
Dim sFname As String
sFname=invPartNumberProperty.Value & ".dwg"
oCompDef.DataIO.WriteDataToFile(sOut,sFname)
oCompDef.ExitEdit
--------------------------------------
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, I tried your fix and it generates another error I haven't seen before:
Error Message:
Error in rule: FLAT PATTERN DWG OUT, in document: B-PANELS.ipt
Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
More Info:
System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.DataIO.WriteDataToFile(String Format, String FileName)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
I found a blog, http://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html
In the middle it shows some sample code where it dims Property Sets before dimming the Property Set, then finally the Property Itself:
SyntaxEditor Code Snippet
' Get the active document. Dim oDoc As Document Set oDoc = ThisApplication.ActiveDocument ' Get the PropertySets object. Dim oPropSets As PropertySets Set oPropSets = oDoc.PropertySets ' Get the design tracking property set. Dim oPropSet As PropertySet Set oPropSet = oPropSets.Item("Design Tracking Properties") ' Get the part number iProperty. Dim oPartNumiProp As Property Set oPartNumiProp = oPropSet.Item("Part Number")
So I tried to insert that step in with the code you provided and came up with this:
SyntaxEditor Code Snippet
Dim oDoc As PartDocument oDoc=ThisApplication.ActiveDocument Dim oCompDef As SheetMetalComponentDefinition oCompDef=oDoc.ComponentDefinition Dim oDataIO As DataIO oDataIO=oDoc.ComponentDefinition.DataIO If oCompDef.HasFlatPattern=False Then oCompDef.Unfold Else oCompDef.FlatPattern.Edit End If Dim sOut As String sOut="FLAT PATTERN DWG?AcadVersion=2000" _ +"&InvisibleLayers=IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL" _ +"&SimplifySplines=True" _ +"&LINEAR TOLERANCE=0.010" _ +"&MergeProfilesIntoPolyline=True" _ +"&RebaseGeometry=False" _ +"&TrimCenterlines=True" Dim invPropSets As PropertySets invPropSets=oDoc.PropertySets Dim invPropSet As PropertySet invPropSet=invPropSets.Item("Design Tracking Properties") Dim invPartNumiProp As Inventor.Property invPartNumiProp=invPropSet.Item("Part Number") Dim sFname As String sFname=invPartNumiProp.Value & ".dwg" oCompDef.DataIO.WriteDataToFile(sOut, sFname) oCompDef.ExitEdit
But it gives the same error code as above, I'll keep digging around for the solution, thanks so much for your help.
I've attached the part file to this reply, please feel free to use it to test your code, I'm sure the solution will be found soon.
Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This code worked fine for me!
Dim oDoc As PartDocument
oDoc=ThisApplication.ActiveDocument
Dim oCompDef As SheetMetalComponentDefinition
oCompDef=oDoc.ComponentDefinition
Dim oDataIO As DataIO
oDataIO=oDoc.ComponentDefinition.DataIO
Dim oFlatPattern As SheetmetalComponentDefinition
If oCompDef.HasFlatPattern=False Then
oCompDef.Unfold
Else
oCompDef.FlatPattern.Edit
End If
Dim sOut As String
sOut="FLAT PATTERN DWG?AcadVersion=2000" _
+"&InvisibleLayers=IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL" _
+"&SimplifySplines=True" _
+"&LINEAR TOLERANCE=0.010" _
+"&MergeProfilesIntoPolyline=True" _
+"&RebaseGeometry=False" _
+"&TrimCenterlines=True"
Dim oPN As String
oPN=oDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
Dim sPath As String
Dim sFname As String
sPath = "C:\Users\Public\Documents\"
sFname= sPath & oPN & ".dwg"
oCompDef.DataIO.WriteDataToFile(sOut, sFname)
oCompDef.FlatPattern.ExitEdit
--------------------------------------
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
Okay, then the issue was when the original code was pulling oDoc.FullFileName, it was pulling the full file path as well, and we didn't put that back and put the Part Number and file type behind that, the code didn't know where to save the file. So we just need to add in a line of code to get the file path and add that to sFname:
SyntaxEditor Code Snippet
Dim oDoc As PartDocument oDoc=ThisApplication.ActiveDocument Dim oCompDef As SheetMetalComponentDefinition oCompDef=oDoc.ComponentDefinition Dim oDataIO As DataIO oDataIO=oDoc.ComponentDefinition.DataIO If oCompDef.HasFlatPattern=False Then oCompDef.Unfold Else oCompDef.FlatPattern.Edit End If Dim sOut As String sOut="FLAT PATTERN DWG?AcadVersion=2000" _ +"&InvisibleLayers=IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL" _ +"&SimplifySplines=True" _ +"&LINEAR TOLERANCE=0.010" _ +"&MergeProfilesIntoPolyline=True" _ +"&RebaseGeometry=False" _ +"&TrimCenterlines=True" Dim invPropSets As PropertySets invPropSets=oDoc.PropertySets Dim invPropSet As PropertySet invPropSet=invPropSets.Item("Design Tracking Properties") Dim invPartNumiProp As Inventor.Property invPartNumiProp=invPropSet.Item("Part Number") Dim sFname As String sFname=ThisDoc.Path & "\" & invPartNumiProp.Value & ".dwg" oCompDef.DataIO.WriteDataToFile(sOut, sFname) oCompDef.FlatPattern.ExitEdit
Thanks for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is this automatically generating the flat patterns on save or anything like that? or could it be programmed to do that? just kinda curious thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Sure.
Ensure you have 2018.1 installed.
Add this to the Event Triggers under Part Documents.
Add some extra lines to make sure it is only exporting them for flat patterns, and not HSS cuts or round bar, or other weird parts and you will be good to go.
--------------------------------------
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
we are not currently running 2018, but that will change in a couple months. I will bring this to everyone's attention though. thank you for letting me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You don't need 2018 for Event Triggers.
For running the code on save, just go to the iLogic section under the Manage tab and click on Event Triggers, then right-click on After Save Document, Select Rules, and then check the box next to the rule you want.
Depending on your needs, if you need the file in DXF format instead of DWG, all you have to do is change the DWG references in the lines
SyntaxEditor Code Snippet
sOut="FLAT PATTERN DWG?AcadVersion=2000" _
And
SyntaxEditor Code Snippet
sFname=ThisDoc.Path &"\"&invPartNumiProp.Value &".dwg"
to "DXF" and ."dxf" appropriately and it will work as well.
If you're interested in a process that will export all flat patterns in one process, here's the code that's used in an assembly file that has all sheet metal parts placed, it doesn't require the previous code to be placed in each sheet metal part, so this will work with any sheet metal part placed as long as there is a flat pattern that can be generated without errors. This also works with iParts for those who use them.
It's a great time saver that did about 80 parts, normal and iParts combined, in a few minutes instead of a few hours when done manually.
SyntaxEditor Code Snippet
Dim oDoc As Document oDoc=ThisDoc.Document Dim docFile As Document For Each docFile In oDoc.AllReferencedDocuments ThisApplication.Documents.Open(docFile.FullFileName,True) Dim partDoc As PartDocument partDoc=ThisApplication.ActiveDocument If partDoc.SubType="{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Dim oCompDef As SheetMetalComponentDefinition oCompDef=partDoc.ComponentDefinition Dim oDataIO As DataIO oDataIO=oDoc.ComponentDefinition.DataIO If oCompDef.HasFlatPattern=False Then oCompDef.Unfold Else oCompDef.FlatPattern.Edit End If Dim sOut As String sOut="FLAT PATTERN DWG?AcadVersion=2000" _ +"&InvisibleLayers=IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL" _ +"&SimplifySplines=True" _ +"&LINEAR TOLERANCE=0.010" _ +"&MergeProfilesIntoPolyline=True" _ +"&RebaseGeometry=False" _ +"&TrimCenterlines=True" Dim invPropSets As PropertySets invPropSets=partDoc.PropertySets Dim invPropSet As PropertySet invPropSet=invPropSets.Item("Design Tracking Properties") Dim invPartNumiProp As Inventor.Property invPartNumiProp=invPropSet.Item("Part Number") Dim sFname As String sFname=ThisDoc.Path &"\"&invPartNumiProp.Value &".dwg" oCompDef.DataIO.WriteDataToFile(sOut,sFname) oCompDef.FlatPattern.ExitEdit If partDoc.ComponentDefinition.IsiPartFactory Or partDoc.ComponentDefinition.IsiPartMember Then partDoc.Save() End If Else End If partDoc.Close Next
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@philip1009wrote:You don't need 2018 for Event Triggers.
For running the code on save, just go to the iLogic section under the Manage tab and click on Event Triggers, then right-click on After Save Document, Select Rules, and then check the box next to the rule you want.
Depending on your needs, if you need the file in DXF format instead of DWG, all you have to do is change the DWG references in the lines
SyntaxEditor Code Snippet
sOut="FLAT PATTERN DWG?AcadVersion=2000" _And
SyntaxEditor Code Snippet
sFname=ThisDoc.Path &"\"&invPartNumiProp.Value &".dwg"to "DXF" and ."dxf" appropriately and it will work as well.
If you're interested in a process that will export all flat patterns in one process, here's the code that's used in an assembly file that has all sheet metal parts placed, it doesn't require the previous code to be placed in each sheet metal part, so this will work with any sheet metal part placed as long as there is a flat pattern that can be generated without errors. This also works with iParts for those who use them.
It's a great time saver that did about 80 parts, normal and iParts combined, in a few minutes instead of a few hours when done manually.
SyntaxEditor Code Snippet
Dim oDoc As Document oDoc=ThisDoc.Document Dim docFile As Document For Each docFile In oDoc.AllReferencedDocuments ThisApplication.Documents.Open(docFile.FullFileName,True) Dim partDoc As PartDocument partDoc=ThisApplication.ActiveDocument If partDoc.SubType="{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Dim oCompDef As SheetMetalComponentDefinition oCompDef=partDoc.ComponentDefinition Dim oDataIO As DataIO oDataIO=oDoc.ComponentDefinition.DataIO If oCompDef.HasFlatPattern=False Then oCompDef.Unfold Else oCompDef.FlatPattern.Edit End If Dim sOut As String sOut="FLAT PATTERN DWG?AcadVersion=2000" _ +"&InvisibleLayers=IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL" _ +"&SimplifySplines=True" _ +"&LINEAR TOLERANCE=0.010" _ +"&MergeProfilesIntoPolyline=True" _ +"&RebaseGeometry=False" _ +"&TrimCenterlines=True" Dim invPropSets As PropertySets invPropSets=partDoc.PropertySets Dim invPropSet As PropertySet invPropSet=invPropSets.Item("Design Tracking Properties") Dim invPartNumiProp As Inventor.Property invPartNumiProp=invPropSet.Item("Part Number") Dim sFname As String sFname=ThisDoc.Path &"\"&invPartNumiProp.Value &".dwg" oCompDef.DataIO.WriteDataToFile(sOut,sFname) oCompDef.FlatPattern.ExitEdit If partDoc.ComponentDefinition.IsiPartFactory Or partDoc.ComponentDefinition.IsiPartMember Then partDoc.Save() End If Else End If partDoc.Close Next
Would we be able to make this export the dxf without the bend lines? This ran flawlessly other that having bend lines on the dxf.
Also I am pretty green (very new) to ilogic and was wondering how to save a rule so you can use it from any file without having to rewrite it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello phillip1009
I'm running your code [Inventor 2018] (copy-paste) and it only generates the iPart member selected.
What about the other ones?
I don't see (not that I know what to look for...) the lines that jump from member to member to save the next flat patterns.
Can you explain/help?
I also need to mention that i haven't been able to save iLogic rules as an external rule (to be used on other files) due to my lack of knowledge and / or the poor user interface of the whole iLogic world.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It sounds like you're trying to export from an iPart Master file, correct?
This code was meant to peruse all files in an assembly file and find sheet metal flats to export, my quick advice would be insert all of your generated iPart files into an assembly saved in the folder you want the flat exports saved to, then run the code.
Otherwise it's a different code to run through the list iPart Members in a Master file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello phillip1009,
You are correct.
I will have to make it...
...or have it made...
Thanks,
Octavio