Automatically Create an iMate on Each Work Point in a Pattern

Automatically Create an iMate on Each Work Point in a Pattern

petestrycharske
Advisor Advisor
668 Views
1 Reply
Message 1 of 2

Automatically Create an iMate on Each Work Point in a Pattern

petestrycharske
Advisor
Advisor

All,

 

I am working on some code to create an iMate on each work point in a pattern.  I think I have everthing down to one line (underlined), but I cannot figure out where I am going astray.  I have been referencing this forum post, but can't figure out what I am doing wrong.  If anyone could give me a tip, I would be greatly appreciative!  If you have any questions, please do not hesitate to contact me.  Hope all is well and have a most blessed day!

 

'Define the Document
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition
oCompDef = oDoc.ComponentDefinition

'Define the work point object
Dim oWorkPoint As WorkPoint

'Define the numbers used to create the work point names
Dim i As Integer
Dim Max_Count As Integer
Max_Count = Row_Count * Column_Count

'Set the first value to zero to negate the Origin Point
i = 0

'Define the iMate creation object
Dim oInsertiMate As InsertiMateDefinition

'Cycle through each work point in the pattern and rename them
For i = 0 To Max_Count
    For Each oWorkPoint In oDoc.ComponentDefinition.WorkPoints
    'Create a new iMate
    oInsertiMate = oCompDef.iMateDefinitions.AddMateiMateDefinition(oWorkPoint, 0, , ,"MatePoint")
    oWorkPoint.Name = "Work Point" & i
    i = i + 1
    Next
Next

iLogicVb.UpdateWhenDone = True

Just a guy on a couch...

Please give a kudos if helpful and mark as a solution if somehow I got it right.
0 Likes
Accepted solutions (1)
669 Views
1 Reply
Reply (1)
Message 2 of 2

petestrycharske
Advisor
Advisor
Accepted solution

All,

 

Nevermind, I figured out where I screwed up and have underlined below.  Turns out that you have to use the MateiMateDefinition if you want to create a Mate iMate...  Who'd have thought of that :>)

 

'Define the Document
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition
oCompDef = oDoc.ComponentDefinition

'Define the work point object
Dim oWorkPoint As WorkPoint

'Define the numbers used to create the work point names
Dim i As Integer
Dim Max_Count As Integer
Max_Count = Row_Count * Column_Count

'Set the first value to zero to negate the Origin Point
i = 0

'Define the iMate creation object
Dim oiMate As MateiMateDefinition

'Cycle through each work point in the pattern and rename them
For i = 0 To Max_Count
    For Each oWorkPoint In oDoc.ComponentDefinition.WorkPoints
    'Create a new iMate
    oiMate = oCompDef.iMateDefinitions.AddMateiMateDefinition(oWorkPoint, 0, , ,"MatePoint")
    oWorkPoint.Name = "Work Point" & i
    i = i + 1
    Next
Next

iLogicVb.UpdateWhenDone = True

Just a guy on a couch...

Please give a kudos if helpful and mark as a solution if somehow I got it right.
0 Likes