How to retrieve workplane constraints

How to retrieve workplane constraints

keithjk
Advocate Advocate
754 Views
6 Replies
Message 1 of 7

How to retrieve workplane constraints

keithjk
Advocate
Advocate

I have a situation where I need to retrieve all component occurances that have a constraint to a particular work plane.  My code below is a start but once I get the contrstraints (in the for loop), I have no idea on how to retrieve the property of the constraint that tells me what it is constrained to.  Any ideas?


Thanks

 

 

Dim occ As ComponentOccurrence

Dim Occurrences As Inventor.ComponentOccurrences = oAssemblyDocument.ComponentDefinition.Occurrences

 

For Each occ In Occurrences

If occ.DefinitionDocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Or _

occ.DefinitionDocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then

myConstraintCount = occ.Constraints.Count

If myConstraintCount > 0 Then

For i = 1 To myConstraintCount

  'how do I get the constraint property that tells me what it is constrained to?

  Debug.Print(occ.Constraints.Item(i).Name)

Next

End If

End If

Next

0 Likes
755 Views
6 Replies
Replies (6)
Message 2 of 7

wispoxy
Advisor
Advisor

by point?

Set occWp = ucs.XYPlane

Set occWp = ucs.XZPlane

Set occWp = ucs.YZPlane

0 Likes
Message 3 of 7

keithjk
Advocate
Advocate

Maybe I could rephrase this question...

 

I need to turn off the visibility of all components that are constrained to a specific workplane.  This sounds like it should be easy but I can't figure it out.  I have a start on my code in my orignal post below.

 

Thanks

0 Likes
Message 4 of 7

wispoxy
Advisor
Advisor
@keithjk not sure about visibility, but I'll look into it.
0 Likes
Message 5 of 7

keithjk
Advocate
Advocate

wisp,

 

I just saw your reply after I posted my 2nd response.  I will give it a try.

0 Likes
Message 6 of 7

wispoxy
Advisor
Advisor

I found the UCS Create Method maybe you can specify / define it to your needs. Then you started talking about visibility, the link doesn't provide visibility though 😞

http://adndevblog.typepad.com/manufacturing/2014/07/create-ucs-constraints.html

0 Likes
Message 7 of 7

Balaji_Ram
Alumni
Alumni

Hi Keith,

 

Will the WorkPlane.Dependents help in your case ?

The following code should list the constraints that are related to the workplane.

 

    Dim oObj As Object
    For Each oObj In oWP.Dependents
        If TypeOf oObj Is AssemblyConstraint Then
            Dim oAsmConstraint As AssemblyConstraint
            Set oAsmConstraint = oObj
            Debug.Print (oAsmConstraint.Name)
        End If
    Next

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes