Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ilogic: Save Copy As Inventor DWG instead of exporting to AutoCAD DWG

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
waynehelley
2785 Views, 5 Replies

Ilogic: Save Copy As Inventor DWG instead of exporting to AutoCAD DWG

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!

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
5 REPLIES 5
Message 2 of 6
waynehelley
in reply to: waynehelley

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")

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Message 3 of 6
GosponZ
in reply to: waynehelley

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)

Message 4 of 6

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

Message 5 of 6

Does anybody know how I can use SaveAsInventorDWG in c# ? Here it doesn't seem to excist 😞
Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 6 of 6

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?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report