Message 1 of 2
Change Mate Offset through API - How?
Not applicable
05-08-2002
10:47 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How does one change the offset value of a named mate constraint through the
API. Seems like there should be a Value property for the MateConstraint.
The only way I could figure out how to do it was to delete the existing
contraint and add a new one. Couldn't get that to work either.
Here's my code. Any ideas? Isn't there an easier way?
This code errors out at the line "Set oMate = ..." with a run-time error
445, "Object doesn't support this action."
Thanks,
--Randy
===========================================
Public Sub SetInsideFrameWidth(Width As Double)
Dim oInventor As Inventor.Application
Set oInventor = GetObject(, "Inventor.Application")
Dim oDoc As AssemblyDocument
Set oDoc = oInventor.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = oDoc.ComponentDefinition
Dim oAssyConstraints As AssemblyConstraints
Dim oAssyConstraint As AssemblyConstraint
Dim oGeom1 As Object
Dim oGeom2 As Object
Set oAssyConstraints = oDoc.ComponentDefinition.Constraints
For Each oAssyConstraint In oAssyConstraints
Debug.Print oAssyConstraint.Name
If oAssyConstraint.Name = "InsideFrameWidth" Then
Set oGeom1 = oAssyConstraint.GeometryOne
Set oGeom2 = oAssyConstraint.GeometryTwo
oAssyConstraint.Delete
Dim oMate As MateConstraint
Set oMate = oAsmCompDef.Constraints.AddMateConstraint(oGeom1,
oGeom2, CStr(Width) & " in")
oMate.Name = "InsideFrameWidth"
Exit Sub
End If
Next
End Sub
API. Seems like there should be a Value property for the MateConstraint.
The only way I could figure out how to do it was to delete the existing
contraint and add a new one. Couldn't get that to work either.
Here's my code. Any ideas? Isn't there an easier way?
This code errors out at the line "Set oMate = ..." with a run-time error
445, "Object doesn't support this action."
Thanks,
--Randy
===========================================
Public Sub SetInsideFrameWidth(Width As Double)
Dim oInventor As Inventor.Application
Set oInventor = GetObject(, "Inventor.Application")
Dim oDoc As AssemblyDocument
Set oDoc = oInventor.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = oDoc.ComponentDefinition
Dim oAssyConstraints As AssemblyConstraints
Dim oAssyConstraint As AssemblyConstraint
Dim oGeom1 As Object
Dim oGeom2 As Object
Set oAssyConstraints = oDoc.ComponentDefinition.Constraints
For Each oAssyConstraint In oAssyConstraints
Debug.Print oAssyConstraint.Name
If oAssyConstraint.Name = "InsideFrameWidth" Then
Set oGeom1 = oAssyConstraint.GeometryOne
Set oGeom2 = oAssyConstraint.GeometryTwo
oAssyConstraint.Delete
Dim oMate As MateConstraint
Set oMate = oAsmCompDef.Constraints.AddMateConstraint(oGeom1,
oGeom2, CStr(Width) & " in")
oMate.Name = "InsideFrameWidth"
Exit Sub
End If
Next
End Sub