Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error when checking HealthStatus of Constraint

0 REPLIES 0
Reply
Message 1 of 1
JanMann84
395 Views, 0 Replies

Error when checking HealthStatus of Constraint

Hi everybody

 

I'm quite new to programming VBA for Inventor but got some experience in programming Visual Basic.

 

I wrote a small macro for assemblies, that constrains all occurrences to the three base planes of the assembly. The macro does this by grounding all occurrences, deleting the existing constraints, checking which planes (base planes of assembly compared to base planes of occurrence) are parallel to each other and then comparing their directions by building the dot product of the normals to add either a mate or a flush constraint.

I didn't figure out an elegant way to define wether the distance is positive or negative (the measure tool only gives positive values). So I just set a constraint with the positive value and then check if it's health status is inconsistent or in error. In this case the constraint is deleted and again added with the negative value. That works good so far.

But after that I'd like to know if the constraint already exists by checking if it's health status is redundant. This is where I get the following error:

 

Run-time error '-2147467259 (80004005)':

Method 'HealthStatus' of object 'FlushConstraint' failed

 

for the following code:

 

dist = Inv.MeasureTools.GetMinimumDistance(Plane(j), AssCompDef.WorkPlanes.Item(2))
 '// Fluchtend
If Plane(j).Plane.Normal.DotProduct(AssCompDef.WorkPlanes.Item(2).Plane.Normal.AsVector.AsUnitVector) > 0 Then
     Set cons = AssCompDef.constraints.AddFlushConstraint(Plane(j), AssCompDef.WorkPlanes.Item(2), dist)
     If cons.HealthStatus = kInconsistentHealth Or cons.HealthStatus = kInErrorHealth Then
          dist = dist * (-1)
          cons.Delete
          Call AssCompDef.constraints.AddFlushConstraint(Plane(j), AssCompDef.WorkPlanes.Item(2), dist)
     End If
     If cons.HealthStatus = kRedundantHealth Then
          cons.Delete
          TextBox1.Text = TextBox1.Text & "Abhängigkeit fluchtend für " & occurrenceList.Item(i).Name & _

          " bereits vorhanden." & vbNewLine & vbNewLine
     Else
          TextBox1.Text = TextBox1.Text & "Abhängigkeit fluchtend für " & occurrenceList.Item(i).Name & " gesetzt:" & _ 

          vbNewLine & "    Zwischen XZ-Ursprungsebene und " & Plane(j).Name & vbNewLine & "    Offset: " & _

          CStr(Format(dist * 10, "######.###")) & "mm" & vbNewLine & vbNewLine
     End If

 

Can anybody tell me why checking the health status works for inconsistent and in error but not for checking redundance?

 

Thanks in advance and greetings from germany.

 

Jan

 

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report