open a drawing in LOD with ilogic

open a drawing in LOD with ilogic

warrentdo
Collaborator Collaborator
1,681 Views
15 Replies
Message 1 of 16

open a drawing in LOD with ilogic

warrentdo
Collaborator
Collaborator

Hello All,

 

 

I have an Ilogic rule that will open a list of drawing on a txt file and create a dwfx for each.

Is it possiable to open the drawings in a specific LOD called 'Simple' before the dxf is created.

I know that you can change the lod onced open before the dwfx is created but can I open straight from the LOD to speed things up?

 

Regards

 

Warren.

 

SyntaxEditor Code Snippet

Imports System.IO
'open and read a text file
Dim oRead As New StreamReader("C:\dwglist.csv")
Dim sLine As String = ""
Dim MyArrayList As New ArrayList

'build list from text file
Do
sLine = oRead.ReadLine()
If Not sLine Is Nothing Then
Dim oDoc As Document
odoc = ThisApplication.Documents.Open(sLine, True)

'CHANGE FILENAME TO SUIT FILE USING THE IPROPERTIES EMBEDDED IN THE PLANT ITEM
FileName = iProperties.Value("Custom", "BUILDING_NO") & "_" & iProperties.Value("Custom", "PLANT_NO") & "_" & iProperties.Value("Project", "Description")

'CHANGE SAVE LOCATION TO SUIT FILE

If iProperties.Value("Custom", "SYSTEM") = "010" Then
SaveLocationDWFX = "C:\10\"
SaveLocationDWG = "C:\10\"

Else If iProperties.Value("Custom", "SYSTEM") = "020" Then
SaveLocationDWFX = "C:\20\"
SaveLocationDWG = "C:\20\"

End If


DWFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD95-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

If DWFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
'PUBLISHES ALL IPROPS WITHIN THE DWFX EXPORT
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oOptions.Value("Launch_Viewer") = 0
oOptions.Value("Publish_All_Component_Props") = 1
oOptions.Value("Publish_All_Physical_Props") = 1
oOptions.Value("Publish_All_User_Defined_Properties_Props") = 1
oOptions.Value("Publish_All_Summary_Information_Props") = 1
oOptions.Value("Publish_All_Document_Summary_Information_Props") = 1
oOptions.Value("Publish_All_Design_Tracking_Properties_Props") = 1
oOptions.Value("Publish_All_TEST_TAB") = 1
oOptions.Value("Password") = 0
oOptions.Value("Publish_Mode") = DWFPublishModeEnum.kCompleteDWFPublish
End If

'Set the destination file name
oDataMedium.FileName = SaveLocationDWFX & FileName & ".dwfx"
oDataMedium.FileName = SaveLocationDWG & FileName & ".dwg"



'Publish document.

Call DWFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
odoc.Close
End If
Loop Until sLine Is Nothing
oRead.Close()
0 Likes
1,682 Views
15 Replies
Replies (15)
Message 2 of 16

MechMachineMan
Advisor
Advisor

api HELP.JPG

 

Yes. Search the programming help for "Documents" and check out the methods available under that.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 16

warrentdo
Collaborator
Collaborator

Hello, I did try the help file but I must of missed the obvious. I didn't think that it will as that spercific in opening a drawing at a lod?

Cheers

Warren.

0 Likes
Message 4 of 16

MechMachineMan
Advisor
Advisor

Since I'm at my computer, I just searched "Documents" and it appears that it's not an easy one to find.

 

Documents is a "sub-object" to the application, so we need to search a level up and find our way down.

 

Do this by:

 

Searching "Application"

Openining it.

Click "Documents" underneath it's properties.

The window should now say "Application.Documents" At the Top.

 

Click "Documents" in about the 3rd line down to get to the Documents Type/Object.

 

Look there.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 5 of 16

Vladimir.Ananyev
Alumni
Alumni

You may change the active level of detail representation of the assembly document represented by the drawing view.  Here is the quick VBA test:

Sub DrawingView_ChangeLOD()
    'active drawing doc
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    'active sheet
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
    'the 1st drawing view
    Dim oView As DrawingView
    Set oView = oSheet.DrawingViews.Item(1)
    
    'specify the custom LoD by its name
    oView.ActiveLevelOfDetailRepresentation = "ONE"
    oSheet.Update
    
    Beep
End Sub

 

If you need to get the list of available LODs you could do it using the DrawingView.ReferencedDocumentDescriptor.ReferencedDocument property that returns the reference to the assembly document:

Sub DrawingView_ListLODs()
    'active drawing doc
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    'active sheet
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
    'the 1st drawing view
    Dim oView As DrawingView
    Set oView = oSheet.DrawingViews.Item(1)
    
    'assume that the referenced document is assembly document
    Dim oAsmDoc As AssemblyDocument
    Set oAsmDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
    Dim oAsmDef As AssemblyComponentDefinition
    Set oAsmDef = oAsmDoc.ComponentDefinition
    
    Dim oRepMgr As RepresentationsManager
    Set oRepMgr = oAsmDef.RepresentationsManager
    
    Dim oLODs As LevelOfDetailRepresentations
    Set oLODs = oRepMgr.LevelOfDetailRepresentations
    
    Dim oLOD As LevelOfDetailRepresentation
    For Each oLOD In oLODs
        Debug.Print oLOD.Name
    Next
End Sub

cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 6 of 16

MechMachineMan
Advisor
Advisor
I think what he is looking for is the functionality offered by:

ThisApplication.Documents.OpenWithOptions (oDoc, options, visibleboolean)

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 7 of 16

Vladimir.Ananyev
Alumni
Alumni

Here are the available options when you open the drawing document in the Inventor UI:

DrawingOptions.png

 

You set the LOD  in the context of the specific DrawingView.  Another DrawingView may represent the same assembly in another LOD in the same drawing document, even on the same sheet.

That's why you have to control the level of detail using the DrawingView API.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 8 of 16

warrentdo
Collaborator
Collaborator

Hello Guy's, the intention was to open the drawing up with the LOD set to BIM.

I dont realy want to open up the drawings and then change the lod.

 

Regards

 

Warren.

0 Likes
Message 9 of 16

MechMachineMan
Advisor
Advisor
You might get the speed increase you are looking for by opening with deferred updates, or by opening documents invisibly.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 10 of 16

warrentdo
Collaborator
Collaborator

Hello,

 

So would it be possible to load the documents invisibly on a LOD?

Could you help in suggesting how to do this?

I really need the latest models so differing updates may not give the required results.

 

Regards,

 

Warren.

0 Likes
Message 11 of 16

MechMachineMan
Advisor
Advisor
As Vlad posted in his thumbnail, you can't actually set a whole .idw to load as a LOD because it is a collection of documents of various LODs.

The only thing you can set for opening an idw is its visibility, deferred updates, and skipping unresolved file references.

Also, the files loaded by an .idw are decided by what is in that .idw. You can't tell an .idw to open an LOD other than what it contains, nor will it function with anything different.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 12 of 16

warrentdo
Collaborator
Collaborator

Hello, would it help if I change the goal post?

 

What if they were only assemblies.

Could I open the Assemblies invisibly on a LOD

I can leave the drawings alone.

 

Regards,

 

Warren.

0 Likes
Message 13 of 16

MechMachineMan
Advisor
Advisor
You can automatically open assemblies to an LOD, yes .

ThisApplication.Documents.OpenWithOptions

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 14 of 16

Davey_van_den_Berg
Contributor
Contributor

Hi,

i'm a litle late but here is the code to add a view in a LOD:

 

Public Sub OpenDocumentInLastActiveLOD()
Dim strFullFileName As String
strFullFileName = "C:\temp\Assembly1.iam"

' Set a reference to the FileManager object.
Dim oFileManager As FileManager
  oFileManager = ThisApplication.FileManager

' Get the name of the last active Level of Detail (LOD) Representation.
Dim strLastActiveLOD As String
strLastActiveLOD = oFileManager.GetLastActiveLevelOfDetailRepresentation(strFullFileName)

' Use the full file name and LOD name to get the full document name.
Dim strFullDocumentName As String
strFullDocumentName = oFileManager.GetFullDocumentName(strFullFileName, strLastActiveLOD)

' Open the document in the last active LOD in memory.
Dim ViewDocument As AssemblyDocument
  ViewDocument= ThisApplication.Documents.Open(strFullDocumentName, False)


oDrawDoc = ThisDrawing.Document

  ASheetFormat = oDrawDoc.SheetFormats.Item("ASheetFormat")


Dim oSheet As Sheet
oSheet = oDrawDoc.Sheets.AddUsingSheetFormat(ASheetFormat, ViewDocument)

End Sub

 

Please mark as solution if it helped

Davey

0 Likes
Message 15 of 16

andrew_canfield
Collaborator
Collaborator

Hello

Is the 'open deferred' option in Inventor 2018 - I don't see drawings included in the application options > files> file open options. (Drawing/DWG only has a 'skip all unresolved files - option)?

Is there iLogic to open an .idw deferred?

Using the code below to open drawings:

	For Each Str As String In aLIST
	   ' System.Console.WriteLine(Str)
		
		ThisDoc.Launch(Str)

		Dim doc As Document = ThisApplication.ActiveDocument

 Regards

 

Andrew

0 Likes
Message 16 of 16

WCrihfield
Mentor
Mentor

Hi @andrew_canfield.  You are right about that option no longer being present in the Application Options.  There is a similar 'Defer update' option  available for assemblies on the Assembly tab, but that's not what you are looking for here.  There is also a setting at the bottom of the Drawing tab called "Enable background updates", that has an effect on performance.  However, this specific settings can still be used when opening a drawing document through code, by using the ThisApplication.Documents.OpenWithAgruments() method, using the NameValueMap, and specifying True or False for that setting called "DeferUpdates" within.  It even specifies that this is specifically for drawings, and what specifically it does.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)