- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I guess the drawing needs to be visibly open to create the flat pattern, but I am not sure about your error message, I would need to test the rule your using.
Here is another example of this rule. It is layout out in VB.net format so a little easier to follow I believe. You can see how some of the filtering is done in the main section of the rule before it calls the sub routine "ExportFlatPatternDXF(oDoc)"
Adapted from rules found here
Sub Main() oAdoc = ThisApplication.ActiveDocument oAcompdef = oAdoc.ComponentDefinition If oAdoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then For Each oDoc As Document In oAdoc.AllReferencedDocuments 'Filtering of documents for processing 'MessageBox.Show(oDoc.FullFileName) If Not oDoc.FullFileName.Contains("Content Center") Then 'Looks at full file name and if it does not contain Content Center it moves to next line If oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then Dim PartDoc As PartDocument = oDoc 'do your stuff here. 'MessageBox.Show( "Check if inside filter") Call ExportFlatPatternDXF(oDoc) Else End If End If Next oDoc End If End Sub Public Sub ExportFlatPatternDXF(oDoc) 'Checks if it is a Sheet metal Part If TypeOf oDoc.ComponentDefinition Is SheetMetalComponentDefinition Then Dim oCompDef As SheetMetalComponentDefinition oCompDef = oDoc.ComponentDefinition If oCompDef.HasFlatPattern = False Then oCompDef.Unfold Else oCompDef.FlatPattern.Edit End If Dim sOut As String sOut = "FLAT PATTERN DXF?AcadVersion=2000&OuterProfileLayer=IV_INTERIOR_PROFILES" NewPath = System.IO.Path.GetDirectoryName(oDoc.fulldocumentname) & "\" MessageBox.Show(NewPath, "Title") Dim sFname As String = NewPath & System.IO.Path.GetFileNameWithoutExtension(oDoc.fulldocumentname) & ".dxf" sFname = ThisDoc.Path & "\" & ThisDoc.FileName(False) & ".dxf" MessageBox.Show(sFname, "Title") MessageBox.Show("DXF SAVED TO: " & sFname ,"DXF Saved", MessageBoxButtons.OK) oCompDef.DataIO.WriteDataToFile( sOut, sFname) End If End Sub
A specific filter is a good idea to target only the parts you want to process. if you want to integrate that. This one will work if you have filtered out the read only files as the ilogic snippet tries to write to the file even if checking the contents and of course it can't as it is read only and will cause an error.
If iProperties.Value(oRefDoc.DisplayName, "Project", "Part Number").ToString.Contains("1234") Then MessageBox.Show(oRefDoc.DisplayName, "Yes ") End If
You can also use the longer property set method through the API to check the part number without excluding read only files.
https://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html
If you want help with the rule post up the one that best suits your needs and it can be easily adapted.
Or if this helped you, please, click (like)
Regards
Alan