occurrence parent = pattern

occurrence parent = pattern

Anonymous
Not applicable
317 Views
1 Reply
Message 1 of 2

occurrence parent = pattern

Anonymous
Not applicable

Hello,

 

I have a external rule that replaces occurrences.

Now I have to make an exclusion for some occurrences in a pattern.

My solution is to check if the occurrence is inside a pattern with a specfic name (oPat.Name.Contains("#Sub"))

 

I made working code the other day , accidently deleted my code, and now I can't replicate it anymore.

 

Note: I do not want to use oOcc.ispatternelement, I want to check the name of the parent if that parent is a pattern.

 

SyntaxEditor Code Snippet

Dim oDoc As AssemblyDocument  = ThisDoc.Document
Dim Occurrences As ComponentOccurrences = oDoc.ComponentDefinition.Occurrences
Dim oOcc As ComponentOccurrence
For Each oOcc In Occurrences
    If oOcc.Parent.Type = ObjectTypeEnum.kOccurrencePatternObject Then
        MsgBox("yay it works")
    End If
Next

 

Thanks in advance

 

Arnold

0 Likes
318 Views
1 Reply
Reply (1)
Message 2 of 2

Vladimir.Ananyev
Alumni
Alumni

If ComponentOccurrence is a pattern member then its ComponentOccurrence.PatternElement.Parent property returns the reference to the parent pattern object:

Dim oOcc As ComponentOccurrence
Set oOcc = oAsmDef.Occurrences.Item(15)  '<--- some component, rect. pattern member
Dim oPattern As RectangularOccurrencePattern 
Set oPattern = oOcc.PatternElement.Parent
Debug.Print oPattern.name

Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes