Design View Representation - Add Using iMates

Design View Representation - Add Using iMates

Anonymous
Not applicable
727 Views
2 Replies
Message 1 of 3

Design View Representation - Add Using iMates

Anonymous
Not applicable

Is there a secret to having the Design View Reps stay on the right settings when using Occurrences.AddUsingIMates? I've got a master top level assembly that I'm bringing other iLogic modules into by using an iLogic form in the master top level assembly. The form calls a rule that makes a copy of the module assembly in the same file location as the master TLA. It then adds the module TLA  to the master TLA using iMates, and calls an external rule to copy all the sub files from the module into that file location and replace them in the module TLA. The user then calls the module's configuration form using a button on the master TLA's form. 

 

I've been using a line of code to set the DVR back to default and associative for the module, but now that has stopped working and it immediately goes back to Master after running the rule, or even if I try and set it by hand. But if I bring the same module in and place it using the Place button, it comes in correctly. I've even added a NameValueMap for the DVR optional argument on AddUsingiMates and that hasn't work. Can anyone help me?

0 Likes
Accepted solutions (1)
728 Views
2 Replies
Replies (2)
Message 2 of 3

Vladimir.Ananyev
Alumni
Alumni

I made a small test. It works according to the help documentation.

If it doesn't help could you post your small test that reproduces the problem.

 

Private Sub iMateDuringOccurrencePlacement_2()

    ' Reference to the active assembly document
    ' (assume that an assembly document is open and activated).
    Dim oAsmDoc As AssemblyDocument
    Set oAsmDoc = ThisApplication.ActiveDocument
    ' Get the component definition of the active assembly.
    Dim oAsmCompDef As AssemblyComponentDefinition
    Set oAsmCompDef = oAsmDoc.ComponentDefinition
    
    Dim oRepMan As RepresentationsManager
    Set oRepMan = oAsmCompDef.RepresentationsManager
    Dim oDVR As DesignViewRepresentation
    
    
    '--------------------
    ' 1st component
    '--------------------
    
    'Activate some custom view representation in the top assembly
    Set oDVR = oRepMan.DesignViewRepresentations.Item(3)
    Call oDVR.Activate
    
    ' Create a new matrix object. It will be initialized to an identity matrix.
    Dim oMatrix As Matrix
    Set oMatrix = ThisApplication.TransientGeometry.CreateMatrix
    
    Dim sPath As String
    sPath = "C:\PR14\Case_Forum\TestPart1.ipt"

    ' Create a new NameValueMap object
    Dim oOptions As NameValueMap
    Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
    Call oOptions.Add("DesignViewRepresentation", "NoWorkFeatures")
    Call oOptions.Add("DesignViewAssociative", True)
    
    ' Place the first occurrence.
    Dim oOcc1 As ComponentOccurrence
    Set oOcc1 = oAsmCompDef.Occurrences.AddWithOptions(sPath, oMatrix, oOptions)
    oAsmDoc.Update
    
    
    '--------------------
    ' 2nd component
    '--------------------
    
    'Activate another custom view representation in the top assembly
    Set oDVR = oRepMan.DesignViewRepresentations.Item(4)
    Call oDVR.Activate
    
    ' Set the representations to use when creating the occurrence.
    oOptions.Clear
    Call oOptions.Add("DesignViewRepresentation", "NoWorkFeatures")
    Call oOptions.Add("DesignViewAssociative", True)

    ' Place the second occurrence, but use iMates for its placement.
    Dim oOccEnumerator As ComponentOccurrencesEnumerator
    Set oOccEnumerator = oAsmCompDef.Occurrences _
            .AddUsingiMates(sPath, False, oOptions)
    oAsmDoc.Update
    oAsmDoc.Save

    ' Since the 'PlaceAllMatching' flag was specified as False,
    ' we can be sure that just one ComponentOccurrence
    ' was returned in the enumerator.
    Dim oOcc2 As ComponentOccurrence
    Set oOcc2 = oOccEnumerator.Item(1)
    
    Beep
End Sub

 Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

Yeah, I figured it out the day after I posted this. I was trying to use the (componentOccurrence).SetDesignViewRepresentation() method to set the rep. Theres a [RESERVED] string argument between the Representation string, and Associativity boolean arguments. Well I guess I just ignored it or something, because as soon as I passed an empty string in its place, it worked. So problem solved.

0 Likes