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:Ā 

Sketch Constriant status

4 REPLIES 4
Reply
Message 1 of 5
bhanukiranss
245 Views, 4 Replies

Sketch Constriant status

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

4 REPLIES 4
Message 2 of 5
theo.bot
in reply to: bhanukiranss

I think your if state ment is incorrect. Try this one

If ptDoc.ComponentDefinition.Sketches.Item(i).ConstraintStatus = kOverConstrainedConstraintStatus Then
MsgBox ("Sketch" &amp; i &amp; " is fully constrained")
ElseIf ptDoc.ComponentDefinition.Sketches.Item(i).ConstraintStatus = kFullyConstrainedConstraintStatus Then
MsgBox ("Sketch" &amp; i &amp; "is fully constrained")
Else
MsgBox ("Sketch" &amp; i &amp; "is not fully constrained")
End if
Message 3 of 5
bhanukiranss
in reply to: theo.bot

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

Message 4 of 5
theo.bot
in reply to: bhanukiranss

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

Message 5 of 5
bhanukiranss
in reply to: theo.bot

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

 

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

Post to forums  

Autodesk Design & Make Report