Hello there,
I previously had an ilogic rule which i used to automate drawing creation. My company has decided that for our new system, all newly created drawings shouldn't be '.dwg's instead of 'idw's.
To remedy this i editted my ilogic codes so that...
oDrawingDoc.SaveAs(location & "\" & DrawingList.Item(i) & ".idw"
becomes
oDrawingDoc.SaveAs(location & "\" & DrawingList.Item(i) & ".dwg"
I though this would be fine but doing this causes the files to be exported as AutoCAD DWGs instead of Inventor DWGs.
Please help!
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
If you are curious, here is the entire code...
question = MessageBox.Show("Is the currently active document the drawing you wish to use as a template? If not, select 'No' then restart the Drawing Generator after opening the drawing which you wish to use as a template", "Drawing Generator",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
'set condition based on answer
If question = vbNo
Exit Sub
End If
spreadsheet = InputBox("The Drawing Generator requires a spreadsheet with a list of drawings you wish to create. Make sure there are no headers or spaces in the spreadsheet and that all member files have been generated. Please enter the location and file name of the spreadsheet you wish to use.", "Drawing Generator", "C:\Work\Designs\Templates\2013\Inventor Templates\Metric\UK iLogic Rules\Drawing\Drawing Generator")
doc = ThisDoc.ModelDocument
'check file type
If doc.DocumentType = kPartDocumentObject Then
extension=".ipt"
Else If doc.DocumentType = kAssemblyDocumentObject Then
extension=".iam"
End If
location = ThisDoc.Path
GoExcel.Open(spreadsheet, "Sheet1")
'create lists
Dim DrawingList As New ArrayList
Dim row As Integer
For row = 1 To 1000
'Exits the FOR function when reaching the end of the list
If (GoExcel.CellValue("A" & row) = "") Then
Exit For
End If
DrawingList.add(GoExcel.CellValue("A"& row))
Next
Dim oString as Object
i = 0
ThisDoc.Document.DrawingSettings.DimensionTextAlignment = DimensionTextAlignmentEnum.kMaintainCenteredTextAlignment
For Each oString in DrawingList
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDrawingDoc.ActiveSheet
'MsgBox(location & "\" & DrawingList.Item(i) & extension)
'replace model reference (needs adjusting to detect if file is part or assembly)
oDrawingDoc.ActiveSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedFileDescriptor.ReplaceReference(location & "\" & DrawingList.Item(i) & extension)
'MsgBox("Test2")
'Detect if the template has a parts list
Try
Dim oPartslistCheck As PartsList
oPartslistCheck = oSheet.PartsLists(1)
partslistpresent=True
Catch
partslistpresent=False
End Try
If partslistpresent=True
'Delete the current parts list
Dim oPartsList As PartsList
oPartsList = oDrawingDoc.ActiveSheet.PartsLists.Item(1)
oPartsList.Delete
' Set a reference to the first drawing view on
' the sheet. This assumes the first drawing
' view on the sheet is not a draft view.
Dim oDrawingView As DrawingView
oDrawingView = oSheet.DrawingViews(1)
' Set a reference to the sheet's border
Dim oBorder As Border
oBorder = oSheet.Border
Dim oPlacementPoint As Point2d
xrev = oBorder.RangeBox.MaxPoint.X
yrev = oBorder.RangeBox.MaxPoint.Y
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(xrev, yrev)
' Create the parts list.
Dim oPartsList1 As PartsList
oPartsList1 = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
oPartsLis1t = oDrawingDoc.ActiveSheet.PartsLists.Item(1)
oPartsList1.Sort("PART NUMBER")
oPartsList1.Renumber
oPartsList1.Style.UpdateFromGlobal
oPartsList1.Style = oDrawingDoc.StylesManager.PartsListStyles.Item("Parts List (ISO)")
oPartsList1.Style = oDrawingDoc.StylesManager.PartsListStyles.Item("Parts List (ANSI)")
End If
oDrawingDoc.SaveAs(location & "\" & DrawingList.Item(i) & ".idw"
i=i+1
Next
ThisDoc.Document.Close(True)
MessageBox.Show("Drawings complete! Wayne is ace.", "Drawing Generator")
oDrawingDoc.SaveAs(location & "\" & DrawingList.Item(i) & ".idw"
Do you missing something in here?
Did you try
ThisDoc.Document.SaveAs(location&"\"&DrawingList.Item(i)&".dwg",True)
Hi
You can also use the SaveAsInventorDWG method.
'True = Save off a copy as a DWG, and keeps the current file open ThisDoc.Document.SaveAsInventorDWG("C:\Temp\Test_001.dwg", True)
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Thank you very much. This is what i'm looking for so long.
But i wonder why there is not "ThisDoc.Document.SaveAsInventorDWG" in the leff panel?