I haven't noticed this before so I don't know if this is a new bug in Inventor 2022.1 or just something I never came across before.
When manually creating a new sketch, construction mode is NOT active.
If I exit a sketch in construction mode and then return to edit the sketch manually, construction mode is NOT active.
I am discovering today that if I leave a sketch manually with construction mode still active, then any sketches created by iLogic/API have all objects in Constructive mode. If I manually go into the sketch created by automation with these objects in construction mode, then construction mode is NOT active.
So has this always been the case and I need to go back through all my iLogic programs and ensure that each object I create is assigned a mode (in case someone left a sketch previously with construction mode still on) or is this a new bug/issue? I've been under the assumption that objects are not in construction mode unless I toggle them to that mode. If this has always been the case, then I've just been very lucky thus far not to have a failure in an iLogic build.
no,
not true
working fine here
What is that iLogic rule doing? Does it change the Construction Property of the sketch lines?
Here's the code, nothing calling for the construction mode
oWorkPlane = oCompDef.WorkPlanes.Item("DXF Plane") oSketch = oCompDef.Sketches.Add(oWorkPlane) oSketch.Name = "Core Sketch" oGC = oSketch.GeometricConstraints oDC = oSketch.DimensionConstraints oCP = oSketch.AddByProjectingEntity(oCompDef.WorkPoints.Item(1)) oHorz = oSketch.SketchLines.AddByTwoPoints(oCP, oTG.CreatePoint2d(TopRad, 0)) oGC.AddGround(oHorz.EndSketchPoint) oTPoly = oSketch.SketchLines.AddAsPolygon(NoSides, oCP, oTG.CreatePoint2d(0, TopRad * 2.54), False) oGC.AddHorizontal(oTPoly.Item(NoSides)) oTmp = oDC.AddOffset(oTPoly.Item(NoSides), oCP, oTG.CreatePoint2d(1, TopRad / 2 * 2.54), False, False) oTmp.Parameter.Value = TopRad * 2.54 oTmp = oDC.AddOffset(oTPoly.Item(NoSides / 4), oCP, oTG.CreatePoint2d(TopRad / 2 * 2.54, 1), False, False) oTmp.Parameter.Value = TopRad * 2.54 oTmp = oDC.AddOffset(oTPoly.Item(NoSides), oTPoly.Item(NoSides / 2), oTG.CreatePoint2d(-1, 0), False, False) oTmp = TopRad * 2 * 2.54 oBPoly = oSketch.SketchLines.AddAsPolygon(NoSides, oCP, oTG.CreatePoint2d(0, BotRad * 2.54), False) oGC.AddHorizontal(oBPoly.Item(NoSides)) oTmp = oDC.AddOffset(oBPoly.Item(NoSides), oCP, oTG.CreatePoint2d(1, BotRad / 2 * 2.54), False, False) oTmp.Parameter.Value = BotRad * 2.54 oTmp = oDC.AddOffset(oBPoly.Item(NoSides / 4), oCP, oTG.CreatePoint2d(BotRad / 2 * 2.54, 1), False, False) oTmp.Parameter.Value = BotRad * 2.54 oTmp = oDC.AddOffset(oBPoly.Item(NoSides), oBPoly.Item(NoSides / 2), oTG.CreatePoint2d(-1, 0), False, False) oTmp = BotRad * 2 * 2.54
Is that the exact rule in your part? When I try to test, it is missing API objects and creates a new sketch every time the rule runs, which is not the behavior seen in your video.
Anyways, I've noticed this behavior in the past, different users having different Sketch formatting options activated [construction, centerpoint, centerline, ...] means the lines created get made by whatever option is set in their environment. I have always made it a point to set my API created sketchEntities to whatever type of line/point format I want it to be so the rule functions as intended for all end users.
You might want to add this to your rule to ensure the created geometry has the formatting you intend.
I've stripped out proprietary coding, attached is the actual file with all the declarations and API objects.
It does kill/wipe any previous sketches and starts anew with each run.
"Anyways, I've noticed this behavior in the past, different users having different Sketch formatting options activated [construction, centerpoint, centerline, ...] means the lines created get made by whatever option is set in their environment. I have always made it a point to set my API created sketchEntities to whatever type of line/point format I want it to be so the rule functions as intended for all end users."
That's what I was thinking I might need to do as I'm doing with Inferred constraints. Can you share that bit of iLogic, I'm not able to dig up that line of API coding.
Here is a snippet of one of my ilogic rules where I create a rectangle that is meant to be construction. You will want to do something similar anytime you create geometry:
'Create rectangle
Dim oRecLines As SketchEntitiesEnumerator = s.Sketchlines.AddAsTwoPointRectangle(CornerPointOne, CornerPointTwo)
For Each l As SketchLine In oRecLines
l.Construction = True 'False for non-construction lines
Next
I just run a short For Loop to set the Construction status of my lines from the EntitiesEnumerator after creating geometry.
I've got changing the mode after creation, I thought you were leading me to a document setting to ensure user changes weren't made from factory defaults for Sketch mode line types. I was curious where that setting was as I wasn't able to dig it up.
[quote
@J-Camper wrote:
"Anyways, I've noticed this behavior in the past, different users having different Sketch formatting options activated [construction, centerpoint, centerline, ...] means the lines created get made by whatever option is set in their environment. I have always made it a point to set my API created sketchEntities to whatever type of line/point format I want it to be so the rule functions as intended for all end users. You might want to add this to your rule to ensure the created geometry has the formatting you intend."
Yeah I thought this was the property when I looked awhile ago, but it does not change the sketch lines format. I then looked for a similar property in SketchOptions Object, but there was nothing that look right.
I finally settled on setting my format after creation, as detailed above.
Can't find what you're looking for? Ask the community or share your knowledge.