ilogic rule: IDW with Flat Pattern

ilogic rule: IDW with Flat Pattern

Anonymous
Not applicable
1,836 Views
12 Replies
Message 1 of 13

ilogic rule: IDW with Flat Pattern

Anonymous
Not applicable

I want to setup an Ilogic rule to export the IDW to DXF if there is a Flat pattern in the drawing.

 

I know how to do the export part but can't find away to detect if there is a view with a flat pattern. 

 

So in summry. How do i know that there is a view is a flatpattern or not?

 

 

0 Likes
1,837 Views
12 Replies
Replies (12)
Message 2 of 13

Anonymous
Not applicable

Ok, How about this.

 

Is there anyway to get access to the part which is in a view?

 

And if so can I see if it has a sheet metal style?

 

Or how about if the view is a depoyment?

 

There must be away to check this? 

 

If I can find a way to see if the part in on the drawing is a sheetmetal with a depoyment then I can save it as a dxf or dwg. 

 

I am sure it is possible but don't know the functions.

0 Likes
Message 3 of 13

mrattray
Advisor
Advisor
It is possible. I'm on my phone right now, but I'll see if I can give you some snippets to help you out. I have code I use that runs on the part level that dumps the flat patten dxf ready for NC programming, which includes error checking that verifies that it's a sheet metal part. I know this can also be accessed from the drawing level, but why do you need to? Can you run from the part?
Mike (not Matt) Rattray

0 Likes
Message 4 of 13

Anonymous
Not applicable

great thanks. It is to fit in with our drawing config system from Noa time. The DXF have to pass the same ruals and it save time to just save the idw as a dxf with all the drawing details. 

 

it also helps the quality control of the compony that does the cutting and folding to get some dimentions on the dxf. 

 

 

0 Likes
Message 5 of 13

mrattray
Advisor
Advisor

Well, that's a lot simpler than what I originally had in mind. Try this:

 

		
Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oSheets As Sheets

Try
	oDoc = ThisDrawing.Document
Catch
	MsgBox("Must be ran on a drawing document!",vbOKOnly,"Error")
	Exit Sub
End Try

oSheets = oDoc.Sheets
For Each oSheet In oSheets
	Try
		If oSheet.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
			Try
				oDoc.SaveAs("C:\Temp\test.dxf", True)
			Catch
				MsgBox("Error saving file",vbOKOnly,"Error")
				Exit Sub
			End Try
		End If
	Catch
		MsgBox("Error detecting file type - probably no views on sheet: " & oSheet.Name,vbOKOnly,"Error")
	End Try
Next

 

That should cycle through every sheet in a drawing file and dump out every sheet that has a view (flat -or- folded) of a sheet metal part to a dxf file at C:\Temp\.

Mike (not Matt) Rattray

0 Likes
Message 6 of 13

Anonymous
Not applicable

WOW. thanks.

 

all I really neded is this 

 

		If oSheet.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"

 

How did you know that it should be a type 

SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
0 Likes
Message 7 of 13

mrattray
Advisor
Advisor
I "borrowed" it from another macro I wrote (along with most of the above code). It probably originally came from one of these boards, but if I had to figure it out on my own I could have used:
msgbox(oSheet.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.SubType)
Mike (not Matt) Rattray

0 Likes
Message 8 of 13

Anonymous
Not applicable

Thank Mike

 

I have somthing funny happen now. The scrips runs and i see it saves the dxf but the file never shows. 

 

So I tried the Export IDW to DXF scrip that is under My Snippets and now I get a zip file with the DXF in it.

 

here is the code that I have

 

 

Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oSheets As Sheets

Try
oDoc = ThisDrawing.Document
Catch
' MsgBox("Must be ran on a drawing document!",vbOKOnly,"Error")
Exit Sub
End Try

oSheets = oDoc.Sheets
For Each oSheet In oSheets
Try
If oSheet.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
Try
'oDoc.SaveAs(ThisDoc.FileName & ".dxf", True)
' Get the DXF translator Add-In.
Dim DXFAddIn As TranslatorAddIn
DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")
'Set a reference to the active document (the document to be published).
Dim oDocument As Document
oDocument = ThisDoc.Document
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMedium As DataMedium
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
' Check whether the translator has 'SaveCopyAs' options
If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
Dim strIniFile As String
strIniFile = "dxfout.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If
'Set the destination file name
oDataMedium.FileName = ThisDoc.PathAndFileName(False) & ".dxf"
MsgBox(oDataMedium.FileName)
'Publish document.
DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

Catch
MsgBox("Error saving file",vbOKOnly,"Error")
Exit Sub
End Try
End If
Catch
'MsgBox("Error detecting file type - probably no views on sheet: " & oSheet.Name,vbOKOnly,"Error")
End Try
Next
0 Likes
Message 9 of 13

mrattray
Advisor
Advisor
Did you try the code exactly as I posted it? I tested that on my end and it worked fine.
Mike (not Matt) Rattray

0 Likes
Message 10 of 13

Anonymous
Not applicable

Hi Mike 

 

This is how i changed your code. just changed the "C:\Temp\test.dxf"  to ThisDoc.PathAndFileName(False) & ".dxf" 

 

 

 

Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oSheets As Sheets

Try
	oDoc = ThisDrawing.Document
Catch
	MsgBox("Must be ran on a drawing document!",vbOKOnly,"Error")
	Exit Sub
End Try

oSheets = oDoc.Sheets
For Each oSheet In oSheets
	Try
		If oSheet.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
			Try
				oDoc.SaveAs(ThisDoc.PathAndFileName(False) & ".dxf", True)
			Catch
				MsgBox("Error saving file",vbOKOnly,"Error")
				Exit Sub
			End Try
		End If
	Catch
		MsgBox("Error detecting file type - probably no views on sheet: " & oSheet.Name,vbOKOnly,"Error")
	End Try
Next

 

0 Likes
Message 11 of 13

Anonymous
Not applicable

Hi Mike

 

So i changed the code as follows. It works now but I get a zip file with the DXF in side. Any idea how i can not get it compressed? 

 

oDocName = ThisDoc.PathAndFileName(False) & ".dxf"
oDoc.SaveAs(oDocName, True)
0 Likes
Message 12 of 13

mrattray
Advisor
Advisor
I copy/pasted the code from your previous post verbatim into a rule in a test file and it works fine for me.
Using the SaveAs() method relies on the settings specified in the applicable ini file. Try taking a look at the settings you have there.
Mike (not Matt) Rattray

0 Likes
Message 13 of 13

mrattray
Advisor
Advisor

Make sure this box is not checked:

 

Capture.PNG

Mike (not Matt) Rattray

0 Likes