Turn several inventor drawing file views in one Autocad File

Turn several inventor drawing file views in one Autocad File

CCarreiras
Mentor Mentor
658 Views
8 Replies
Message 1 of 9

Turn several inventor drawing file views in one Autocad File

CCarreiras
Mentor
Mentor

Hi!

 

Scenario: There's a few  dwg (or dxf) files in a folder. Each drawing as only one view.

 

It's possible to create a iLogic Rule to:

 

copy all this drawing views to just one Autocad file (all inventor views in the autocad file , paste the views in the modelspace)

or

copy each views from the several drawings and pastey all them in a new Inventor's  file, all views in the same sheet.

 

Any thoughts?

 

Thanks.

CCarreiras

EESignature

0 Likes
659 Views
8 Replies
Replies (8)
Message 2 of 9

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Yes this is possible:

 

take this code and put in your I-logic.

'Public Sub dwg()
Dim a As Application
a = ThisApplication

Dim Copydwgfrom As DrawingDocument
'put here your dwg full file name where to copy from Copydwgfrom = a.Documents.Open("C:\Vault\Projects\w2.dwg", False) Dim Copydwgto As DrawingDocument Copydwgto = a.ActiveDocument Dim shCopy As Sheet shCopy = Copydwgfrom.Sheets.Item(1) Call shCopy.CopyTo(Copydwgto) 'End Sub

Then afterwards you can manually export to autocad dwg.

or with this coding:

 

''Public Sub PublishDWG()
    ' Get the DWG translator Add-In.
    Dim DWGAddIn As TranslatorAddIn
     DWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}")

    'Set a reference to the active document (the document to be published).
    Dim oDocument As Document
     oDocument = ThisApplication.ActiveDocument

    Dim oContext As TranslationContext
     oContext = ThisApplication.TransientObjects.CreateTranslationContext
    oContext.Type = 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 DWGAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then

        Dim strIniFile As String
		'first create an ini file manually with the export options
		'this will be needed to define the export settings
        strIniFile = "C:\tempDWGOut.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 = "c:\tempdwgout.dwg"

    'Publish document.
    Call DWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
'End Sub

 

 

if help is neede please ask.

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 9

CCarreiras
Mentor
Mentor

HI!

 

Thanks, it's a good start.

 

Ok, it works for one document, but the workflow is to do it to all documents in the folder.

 

A good scenario will be to select a folder and then the rule will run the task for every dwg file inside the folder.

 

Thanks.

CCarreiras

EESignature

0 Likes
Message 4 of 9

bradeneuropeArthur
Mentor
Mentor

 

Changes like this:

 

Look in Directory C:\tests

 

Dim a As Application
a = ThisApplication

'Your directory here!!! Dim oDir As System.IO.DirectoryInfo = New System.IO.DirectoryInfo("C:\Tests") Dim fio() As System.IO.FileInfo = oDir.GetFiles() 'MsgBox(fio.Count) 'a.GetFiles() Dim f As System.IO.FileInfo For Each f In fio If f.FullName.Contains(".dwg") Then Copydwgfrom = a.Documents.Open(f.FullName, False) End If Next Dim Copydwgfrom As DrawingDocument Dim Copydwgto As DrawingDocument Copydwgto = a.ActiveDocument Dim shCopy As Sheet shCopy = Copydwgfrom.Sheets.Item(1) Call shCopy.CopyTo(Copydwgto)

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 9

CCarreiras
Mentor
Mentor

 

 

Did you test the rule?

 

"Copydwgfrom cannot be referred to befote it is declared", so, i moved ti up.

Nevertheless, the rule doesnt work, Unspecified error.

 

Tryed to make some changes, but still dont work...

 

Thanks.

CCarreiras

EESignature

0 Likes
Message 6 of 9

bradeneuropeArthur
Mentor
Mentor

Yes you are right.

 

I need to copy it form vb.net.

 

That went wrong!

 

I will test again.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 7 of 9

bradeneuropeArthur
Mentor
Mentor

Rewritten and tested:

 

Dim a As Application
a = ThisApplication
Dim oDir As System.IO.DirectoryInfo = New System.IO.DirectoryInfo("C:\Tests")
Dim fio() As System.IO.FileInfo = oDir.GetFiles()
MsgBox(fio.Count)
'a.GetFiles()
Dim f As System.IO.FileInfo

Dim Copydwgfrom As Inventor.Document
Dim Copydwgto As DrawingDocument
Copydwgto = a.ActiveDocument
Dim shCopy As Sheet
'Copydwgfrom = 
For Each f In fio
	

    If f.FullName.Contains(".dwg") Then

		Copydwgfrom = a.Documents.Open(f.FullName, False)
		shCopy = Copydwgfrom.Sheets.Item(1) 
		Call shCopy.CopyTo(Copydwgto)
    End If
Next

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 8 of 9

CCarreiras
Mentor
Mentor

 

OK, it works in a simple way.

 

My aim is to read each file in test folder, copy the views, and paste all copied views, in only one sheet in the new drawing. Now is pasting each view in one new sheet.

 

Any chance to paste all the copied views in the same sheet?

 

Also, if the source files have more then one sheet, it's possible to bring all sheets instead the first one?

 

Thanks.

CCarreiras

EESignature

0 Likes
Message 9 of 9

bradeneuropeArthur
Mentor
Mentor

 

Simple as it is...

Copy instead the views to the current sheet.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes