Skip to main content
HamsterNL
18-Opal
March 17, 2017
Solved

VBA - Constraint Offset

  • March 17, 2017
  • 1 reply
  • 1488 views

Does anyone have an exampl on how the create an ALIGN OFFSET constraint in VBA (I am automating from MS Excel)

My code fails when I try to supply an Offset:

        Set asmItem = assemblyModelItemOwner.GetItemByName(EpfcModelItemType.EpfcITEM_SURFACE, assemblyDatums(i))

        Set compItem = componentModelItemOwner.GetItemByName(EpfcModelItemType.EpfcITEM_SURFACE, componentDatums(i))

       

        Set ids = New Cintseq

       

        Dim OCMAssembly As New CMpfcAssembly

        Set path = OCMAssembly.CreateComponentPath(assembly, ids)

       

        Dim oCMSelect As New CMpfcSelect

        Set asmSelect = oCMSelect.CreateModelItemSelection(asmItem, path)

        Set compSelect = oCMSelect.CreateModelItemSelection(compItem, Nothing)

       

        Dim oCCComponentConstraint As New CCpfcComponentConstraint

        Set constraint = oCCComponentConstraint.Create(EpfcComponentConstraintType.EpfcASM_CONSTRAINT_ALIGN_OFF)

       

        constraint.AssemblyReference = asmSelect

        constraint.ComponentReference = compSelect

        ''constraint.Offset = 10 '' <--- CODE FAILS HERE

        Call constraints.Insert(constraints.Count, constraint)

Best answer by HamsterNL

Solution is to convert the value to a double:

constraint.Offset = CDbl(100)

1 reply

HamsterNL
HamsterNL18-OpalAuthorAnswer
18-Opal
March 17, 2017

Solution is to convert the value to a double:

constraint.Offset = CDbl(100)