Hi All
i have written a code to check the constaint status of sketches. But every time it was returning the value that sketches are under constraint what ever might be status.
So any one help me out from this, please
Sub changeSketchname()
Dim ptDoc As PartDocument
Dim ptDocDef As PartComponentDefinition
If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then
MsgBox "please open a part document"
Exit Sub
End If
Set ptDoc = ThisApplication.ActiveDocument
Set ptDocDef = ptDoc.ComponentDefinition
Dim Sketch As PlanarSketch
Dim j As Integer
Dim prefix As String
MsgBox "Total number of Sketches = " & ptDoc.ComponentDefinition.Sketches.Count
prefix = "Sketch"
j = 1
For Each Sketch In ptDoc.ComponentDefinition.Sketches
Sketch.Name = prefix + CStr(j)
j = j + 1
Next
Dim i As Integer
For i = 1 To ptDoc.ComponentDefinition.Sketches.Count
MsgBox ptDoc.ComponentDefinition.Sketches.Item(i).Name
If ptDoc.ComponentDefinition.Sketches.Item(i).ConstraintStatus <> kOverConstrainedConstraintStatus Then
MsgBox ("Sketch" & i & " is not fully constrained")
ElseIf ptDoc.ComponentDefinition.Sketches.Item(i).ConstraintStatus = kFullyConstrainedConstraintStatus Then
MsgBox ("Sketch" & i & "is fully constrained")
End If
Next
End Sub
Hi
Thanks for your reply, but it still dont work...:(
same error...ever sketch has same status either fully or underconstraint...it is saying all sketches are under constraint
I check it again but it works fine.
Sub changeSketchname()
Dim ptDoc As PartDocument
Dim ptDocDef As PartComponentDefinition
If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then
MsgBox "please open a part document"
Exit Sub
End If
Set ptDoc = ThisApplication.ActiveDocument
Set ptDocDef = ptDoc.ComponentDefinition
Dim Sketch As PlanarSketch
Dim j As Integer
Dim prefix As String
MsgBox "Total number of Sketches = " & ptDoc.ComponentDefinition.Sketches.Count
prefix = "Sketch"
j = 1
For Each Sketch In ptDoc.ComponentDefinition.Sketches
Sketch.Name = prefix + CStr(j)
j = j + 1
Next
Dim i As Integer
For i = 1 To ptDoc.ComponentDefinition.Sketches.Count
MsgBox ptDoc.ComponentDefinition.Sketches.Item(i).Name
If ptDoc.ComponentDefinition.Sketches.Item(i).ConstraintStatus = kOverConstrainedConstraintStatus Then
MsgBox ("Sketch" & i & " is fully constrained")
ElseIf ptDoc.ComponentDefinition.Sketches.Item(i).ConstraintStatus = kFullyConstrainedConstraintStatus Then
MsgBox ("Sketch" & i & " is fully constrained")
Else
MsgBox ("Sketch" & i & " is not fully constrained")
End If
Next
End Sub
heck also this : http://forums.autodesk.com/t5/inventor-customization/ilogic-underconstrained-sketches/td-p/3104766
Hi
First of all..thanks for your time...
I find out the problem, the problem is if we constraint sketch using project geomentry, though the sketch shows fully constrained with a pin symbol on sketch. Still the code says that the sketch is under constraint.
I dont know whether i need to include any formats or any logic, so that the code runs properly by identofying projected geometry too