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: 

INV 2010 - VBA DWF Publish options - Positional Reps and Design View Reps

0 REPLIES 0
Reply
Message 1 of 1
RPdAnjou
1005 Views, 0 Replies

INV 2010 - VBA DWF Publish options - Positional Reps and Design View Reps

Hi,

 

For our automtisation macro, I've been trying to include assembly View reps and/or Pos Reps in the DWF publish process.

After a lot of searching, I created two functions that can be used as a addition to the "Export to DWF" example macro in the "Inventor API help".

 

I like to shere them with you because I could not find a simple ready to use example.

 

'Adds all current Design View Representations from the specified assembly document to the specified DWF publish options
Private Sub AddAllDesignViewRepresentationOptions(ByVal oAssyDoc As AssemblyDocument, ByVal oOptions As NameValueMap)
    
    'Set reference to the design view representations
    Dim oDesViewReps As DesignViewRepresentations
    Set oDesViewReps = oAssyDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations
    
    If oDesViewReps.Count > 0 Then
        'Add all design view representations to the publish options
        Dim oDesViewRep As DesignViewRepresentation
        Dim oDesViewRepNVM As NameValueMap
        Dim oDesViewRepOptions As NameValueMap
        Set oDesViewRepOptions = ThisApplication.TransientObjects.CreateNameValueMap
        Dim i As Integer
        i = 0
        'loop trough all design view reps
        For Each oDesViewRep In oDesViewReps
            i = i + 1
            Set oDesViewRepNVM = ThisApplication.TransientObjects.CreateNameValueMap
            oDesViewRepNVM.Add "Name", oDesViewRep.Name
            oDesViewRepOptions.Value("Design_View" & i) = oDesViewRepNVM
        Next
        oOptions.Value("Design_Views") = oDesViewRepOptions
    End If
    
End Sub

'Adds all current Positional Representations from the specified assembly document to the specified DWF publish options
Private Sub AddAllPositionalRepresentationOptions(ByVal oAssyDoc As AssemblyDocument, ByVal oOptions As NameValueMap)
    
    'Set reference to the positional representations
    Dim oPosReps As PositionalRepresentations
    Set oPosReps = oAssyDoc.ComponentDefinition.RepresentationsManager.PositionalRepresentations
    
    If oPosReps.Count > 0 Then
        'Add all positional representations to the publish options
        Dim oPosRep As PositionalRepresentation
        Dim oPosRepNVM As NameValueMap
        Dim oPosRepOptions As NameValueMap
        Set oPosRepOptions = ThisApplication.TransientObjects.CreateNameValueMap
        Dim i As Integer
        i = 0
        'Loop trough all pos reps
        For Each oPosRep In oPosReps
            i = i + 1
            Set oPosRepNVM = ThisApplication.TransientObjects.CreateNameValueMap
            oPosRepNVM.Add "Name", oPosRep.Name
            oPosRepOptions.Value("Positional_Representation" & i) = oPosRepNVM
        Next
        oOptions.Value("Positional_Representations") = oPosRepOptions
    End If
    
End Sub

 

If you added the code above, you can add this piece of code to the macro example from the "Inventor API help" or to you own custom DWF publish code.

If TypeOf oDoc Is AssemblyDocument Then
     'Set custom DWF publish mode
     oOptions.Value("Publish_Mode") = kCustomDWFPublish
        
     'Set reference to the assembly document
     Dim oAssyDoc As AssemblyDocument
     Set oAssyDoc = oDoc
        
     'Add all design view reps to the publish options
     AddAllDesignViewRepresentationOptions oAssyDoc, oOptions
     'Add all pos reps to the publish options
     AddAllPositionalRepresentationOptions oAssyDoc, oOptions
End If

 

Hope it helpes! 

0 REPLIES 0

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

Post to forums  

Autodesk Design & Make Report