cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

VBA - Constraint Offset

HamsterNL
18-Opal

VBA - Constraint Offset

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)

1 ACCEPTED SOLUTION

Accepted Solutions

Solution is to convert the value to a double:

constraint.Offset = CDbl(100)

View solution in original post

1 REPLY 1

Solution is to convert the value to a double:

constraint.Offset = CDbl(100)

Top Tags