iLogic sketch - bad value results & ExitEdit errors (Inv 2021)

iLogic sketch - bad value results & ExitEdit errors (Inv 2021)

llorden4
Collaborator Collaborator
945 Views
1 Reply
Message 1 of 2

iLogic sketch - bad value results & ExitEdit errors (Inv 2021)

llorden4
Collaborator
Collaborator

Learning about sketching in a part file, I've run into a few issues that I wanted to reach out for development feedback on.

 

Issue #1 - ExitEdit

I'm finding I don't need the "ExitEdit" option when completing a sketch, using it only creates an error.  I've found one example that used the "Solve" option prior to calling the exit, but this does not prevent the error.

oSketch.Solve
oSketch.ExitEdit

In my current task, I need to create two separate sketches prior to creating the feature and it assumed I'd need the exit feature before starting the next sketch.  Turns out I don't, but I'm curious why/where this option would be needed.   Attempting to use these exit features currently yields the following error:

Capture1.PNG

 

 

Issue #2 - Bad value results

I'm using a sketch to derive a value for me I've not found a trig formula for as yet.  I need to find the resulting angle based upon some geometric references to an arc length from a known point in space.  Creating a derived sketch and placing a driven dimension seems like a simple approach, however the value result of the driven dimension doesn't match the displayed result.  Here's the code snippet:

 

'Create derived sketch to obtain needed values
oWorkPlane = oCompDef.WorkPlanes("XY Plane")
oSketch = oCompDef.Sketches.Add(oWorkPlane)											'create sketch on workplane
oSketch.Name = "Derived Sketch"
oBot = oSketch.AddByProjectingEntity(oArc(0))	
	oBot.Construction = True
oCP1 = oSketch.AddByProjectingEntity(oArc(0).CenterSketchPoint)						'center point of outer edge radius
oCP2 = oSketch.AddByProjectingEntity(oCompDef.WorkAxes.Item("Hole Axis"))			'center of hole location
oLine(0) = oSketch.SketchLines.AddByTwoPoints(oCP1, oTG.CreatePoint2d(oQuad.X - 2, oQuad.Y))
oLine(1) = oSketch.SketchLines.AddByTwoPoints(oLine(0).EndSketchPoint, oCP2)
oLine(2) = oSketch.SketchLines.AddByTwoPoints(oLine(1).EndSketchPoint, oTG.CreatePoint2d(oQuad.X + 2, oQuad.Y))
oLine(3) = oSketch.SketchLines.AddByTwoPoints(oLine(2).EndSketchPoint, oLine(0).StartSketchPoint)
oGC = oSketch.GeometricConstraints
oGC.AddCoincident(oLine(0).EndSketchPoint, oBot)									'constrain to outer edge radius
oGC.AddCoincident(oLine(2).EndSketchPoint, oBot)									'constrain to outer edge radius
oGC.AddEqualLength(oLine(1),oLine(2))												'ensure orientation is symmetrical
oTmp = oSketch.DimensionConstraints.AddTwoLineAngle(oLine(1),oLine(2),oQuad, False)	'create right angle constraint
		oTmp.Parameter.Value = 90 * PI / 180
oTmp = oSketch.DimensionConstraints.AddTwoLineAngle(oLine(0),oLine(3),oQuad, True)	'create driven angle to find angle result
Dim oDrAngle As Double = oTmp.Parameter.Value
MsgBox(oDrAngle)
'oSketch.Solve
'oSketch.ExitEdit

The driven angle result is stored to the variable "oDrAngle" and displays in radians as follows:

llorden4_0-1595345761269.png

And converts to 4.395 degrees

 

Passing along the value to the revolve cut feature falls short of the desired intersection points, verifying that the value is clearly short of the intended location.

Capture3.PNG

Can anyone explain why the value is not being returned correctly and what needs to be done in order to reach the correct value?

Autodesk Inventor Certified Professional
0 Likes
Accepted solutions (1)
946 Views
1 Reply
Reply (1)
Message 2 of 2

llorden4
Collaborator
Collaborator
Accepted solution

After a bit of playing I was able to figure out a couple of things...

 

The .Solve option is basically a refresh/update command, adding this command prior to the driven dimension allowed the value to update with the correct value.

 

The .ExitEdit option appears to be used only to exit sketch mode if iLogic is fired while sketch mode is already active by the user, giving the iLogic an opportunity to close that mode.  I'd love to hear if there are other uses.

 

For anyone following along, the amended code is as follows:

oTmp = oSketch.DimensionConstraints.AddTwoLineAngle(oLine(1),oLine(2),oQuad, False)	'create right angle constraint
	oTmp.Parameter.Value = 90 * PI / 180
oTmp = oSketch.DimensionConstraints.AddTwoLineAngle(oLine(0), oLine(3), oQuad, True)	'create driven angle to find angle result
oSketch.Solve
oDrAngle = oTmp.Parameter.Value

 

Autodesk Inventor Certified Professional
0 Likes