PositionalRepresentation.SetConstraintValueOverride ==> use of parameter

PositionalRepresentation.SetConstraintValueOverride ==> use of parameter

Anonymous
Not applicable
606 Views
3 Replies
Message 1 of 4

PositionalRepresentation.SetConstraintValueOverride ==> use of parameter

Anonymous
Not applicable

Hi there,

 

I have an assembly with two parts connected with a mate constraint. In the assembly there is a parameter 'Offset' present but somehow the below code fails on the line 'Call oPosRep.SetConstraintValueOverride(oConstraint, "Offset")'.

 

When I manually create a PosRep with an override on the mate constraint I am allowed to use the 'Offset' parameter. So why doesn't this work from VBA?

 

Note that the below code does work if I replace 'Offset' with a numeric value.

 

Sub CreatePosRep()
    
    Dim oAssCompDef As AssemblyComponentDefinition
    Set oAssCompDef = ThisApplication.ActiveDocument.ComponentDefinition
    
    Dim oPosRep As PositionalRepresentation
    Set oPosRep = oAssCompDef.RepresentationsManager.PositionalRepresentations.Add("PosRep1")
    
    Dim oConstraint As AssemblyConstraint
    Set oConstraint = oAssCompDef.Constraints(1)
    
    Call oPosRep.SetConstraintValueOverride(oConstraint, "Offset")

End Sub

 

Hopefully someone can shed some light on this case.

 

Best regards, Daniël

 

IV2013 Professional SP2 Update 5

 

 

 

0 Likes
607 Views
3 Replies
Replies (3)
Message 2 of 4

Vladimir.Ananyev
Alumni
Alumni

I suppose you experience the problem with he second argumrnt in the SetConstraintValueOverride method. Method expects the expression like “28 mm”.  The following code works for me:

 

Sub CreatePosRep()
    
    Dim oAssCompDef As AssemblyComponentDefinition
    Set oAssCompDef = ThisApplication.ActiveDocument.ComponentDefinition
    
    Dim oPosRep As PositionalRepresentation
    On Error Resume Next
    Set oPosRep = oAssCompDef.RepresentationsManager.PositionalRepresentations.Add("PosRep1")
    If Err <> 0 Then
      Set oPosRep = oAssCompDef.RepresentationsManager.PositionalRepresentations.Item("PosRep1")
    End If
    
    Dim oConstraint As AssemblyConstraint
    Set oConstraint = oAssCompDef.Constraints.Item("GAP")
    
    Call oPosRep.SetConstraintValueOverride(oConstraint, "15 mm")
  
  Beep
End Sub

 cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 4

Anonymous
Not applicable

Yes, as I already indicated in my first post the code does work if I use a numeric value. So "15" or "15 mm" does work as expected. However the use of a parameter does not work from the code. But I can use a parameter if I manually create an override constraint.

 

Daniël

0 Likes
Message 4 of 4

YuhanZhang
Autodesk
Autodesk

Hi Daniel,

 

This should be a defect, I logged it as 1517815, you can provide this number to us to check its status.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes