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