Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IFRs on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking Journal Constraints VB 1

Status
Not open for further replies.

Twullf

Mechanical
Jan 24, 2012
196
I have been trying to check various sources but haven't found any examples.

Basically I want to put a line, constrained vertically, and set it tangent to an arc in a sketch. Then I want the automation to check for conflicting constraints.

The first part is easy enough, but I haven't been able to find any examples to check for over-constraints or conflicting-constraints.

I found Public Enumeration which looks promising but I'm unsure how to use it.

If anyone has any advice on where I can find additional resources I have checked the following

NX 7.5 Help Library
GTAC and this site

I am running Windows 7
NX 7.5
 
Replies continue below

Recommended for you

I have been struggling with this for several days.

This is the code I have been able to come up with but though I don't get an error the If(sketch1.status.OverConstrained ) always appears to enter the if statement rather than only entering if the sketch is over constrained.

Code:
            If boolCreateRoot = True then
               CreateRoot( transform, lineChord, lineTE )
            Else
               CreateVertLine( transform, lineChord, vertLine )
               markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Create Geometric Constraints")
               ConstrainTangent( vertLine, botSpline )

               If( sketch1.status.OverConstrained )
                  'theSession.UndoLastNVisibleMarks( 1, marksRecycled1, undoUnavailable1 )
                  'ConstrainTangent( vertLine, topSpline )
               End If

            End If

Any help would be greatly appreciated.
 
I am still fighting this cod my current If statement to check to see if the sketch is over constrained is as follows:
Code:
   '------------------------------------------------------------------------------------------
   'Create the veritical line in subrouting, works well
   '------------------------------------------------------------------------------------------

   CreateVertLine( transform, lineChord, vertLine )

   '------------------------------------------------------------------------------------------
   'Set Undo location
   '------------------------------------------------------------------------------------------

   markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Create Geometric Constraints")

   '------------------------------------------------------------------------------------------
   'Constrain previously created line with spline, works well
   '------------------------------------------------------------------------------------------

   ConstrainTangent( vertLine, botSpline )
   Dim stat As Integer 

   '------------------------------------------------------------------------------------------
   'receives no error, I assume GetStatus is being used properly
   '------------------------------------------------------------------------------------------

   status1 = sketch1.GetStatus( stat )


   '------------------------------------------------------------------------------------------
   'Check to see if the sketch is over constrained, If statement never entered but no error generated
   '------------------------------------------------------------------------------------------

   If( status1 = sketch1.Status.OverConstrained )
      theSession.UndoLastNVisibleMarks( 1, marksRecycled1, undoUnavailable1 )
      ConstrainTangent( vertLine, topSpline )
   End If

Any help would be greatly appreciated.
I would really appreciate any insight available. Thanks.
 
Two things:

Code:
If( status1 = sketch1.Status.OverConstrained )

[ol 1]
[li]The if statement seems to have no "then" statement associated with it.[/li]
[li]Instead of "status1 = sketch1.Status.OverConstrained", try "status1 = Sketch.Status.OverConstrained"[/li]
[/ol]

www.nxjournaling.com
 
I have made the suggested changes, but no change.

the If statement is not being entered. I have tried it two different ways.

Code:
   If status1 = sketch.Status.OverConstrained Then
      theSession.UndoLastNVisibleMarks( 1, marksRecycled1, undoUnavailable1 )
      ConstrainTangent( vertLine, topSpline )
   End If
and

Code:
   If stat1 = sketch.Status.OverConstrained Then
      theSession.UndoLastNVisibleMarks( 1, marksRecycled1, undoUnavailable1 )
      ConstrainTangent( vertLine, topSpline )
   End If

both have the same result, there is no error generated but the if statement is not being entered.
 
Are you 100% sure the sketch in question is overconstrained? You may also want to check for inconsistent constraints (Sketch.Status.InconsistentlyConstrained).

www.nxjournaling.com
 
When I go into the sketch that should be being effected by the IF statement, UG has the notice at the top of the window saying "Sketch contains conflicting constraints"

I have tried to use the inconsistent as well as over and neither gives me an error, though neither enters the If statement either.
 
Possibly, I'll try and mock one up tonight unfortunatly they are real sticklers here about proprietary information so I'll have to make sure I don't put to much in it.

Just got pulled off onto something else so this will now have to wait till I get time again.
 
I had a moment to whip up a quick example, that I think follows your intent.
Sketch:001 in the part file is fully constrained, if you run the journal it will try to create a tangent constraint, detect the overconstrained sketch and perform an undo operation. If you edit the p8 dimension to be reference before running the journal, it will successfully create the tangent constraint.


www.nxjournaling.com
 
It is still not working but it appears the code is "Correct" even if it isn't doing what I want it to do. So back to basics.

I'm including a picture of the sketch. I have two spline creating an airfoil, I need the vertical line to be set tangent to one of those spline, but depending on the angle of the airfoil changes which spline needs to be selected to set the tangency constraint.

I believe you were right that this should be InconsistentlyContrained, but it is not working and I used the same callout in the if statement as in your example. My best guess is I'm not checking for the right error.

Code:
   CreateVertLine( transform, lineChord, vertLine )
   markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Create Geometric Constraints")
   ConstrainTangent( vertLine, botSpline )
   Dim stat As Integer 

   If sketch1.GetStatus( stat ) = sketch.Status.InconsistentlyConstrained Then
      theSession.UndoLastNVisibleMarks( 1, marksRecycled1, undoUnavailable1 )
      ConstrainTangent( vertLine, topSpline )
   End If
   theSession.ActiveSketch.Update()
 
 http://files.engineering.com/getfile.aspx?folder=db740213-3cd6-4331-880d-0982ec875c0d&file=sketch_issues.JPG
Got it, the sketch needed to be updated before it would realize the sketch was inconsistently constrained.

Added the callout and now it works.

Thanks for your help you really are a great help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor