MoveSketchObjects method moves sketch by doubling its vector value

MoveSketchObjects method moves sketch by doubling its vector value

Mehmet_Fatih_Turker
Advocate Advocate
175 Views
2 Replies
Message 1 of 3

MoveSketchObjects method moves sketch by doubling its vector value

Mehmet_Fatih_Turker
Advocate
Advocate

Hi all, 

 

I got problem with MoveSketchObjects method. Here below I shared just part of the code that I believe we can find solution from.  Otherwise it would be too long to share whole code.

Program draws rectangle side by side and makes coolinear their sides then collects currently drawn rectangle and drag to location where before-rectangle corner located. And does this to each rectangle one by one as shown below. ( Also other features I have but its not our case right now)

Mehmet_Fatih_Turker_0-1736596376033.png

 

Problem here is that MoveSketchObjects method moves first rectangle by 1 mm on each do loop to down and this is actually want I want. But at the second and following rectangle, it moves by 2 mm on each do loop. Why Im seeing this behavior? anyone faced anything like this before ?

 

'' Code here...

Dim SketchforBoyunduruk As PlanarSketch = oPartCompDef.Sketches.Add(oPartCompDef.WorkPlanes.Item(2))
Dim oVec As Vector2d = g_inventorApplication.TransientGeometry.CreateVector2d(0, -0.1)
Dim oSketchObjects As ObjectCollection = g_inventorApplication.TransientObjects.CreateObjectCollection
Dim oSketchEntity As SketchEntity = Nothing

'' Code here...

Dim tolerance As Double = 0.001

Dim cornerPositionofFirstRect As Double = firstPointofSecondLine.Geometry.Y
Dim yPositionofFirstPointofSecondLine As Double = firstPointofSecondLine.Geometry.Y

'' Code here...

Dim currentRectangleLines As SketchEntitiesEnumerator = SketchingTool.DrawRectangle(SketchforBoyunduruk, adjustedLength, adjustedWidth, emptiedRectCheck)

'' Code here...

For Each oSketchEntity In currentRectangleLines
     oSketchObjects.Add(oSketchEntity)
Next

Do While Math.Abs(cornerPositionofFirstRect -yPositionofFirstPointofSecondLine) > tolerance
                        
     SketchforBoyunduruk.MoveSketchObjects(oSketchObjects, oVec)
     yPositionofFirstPointofSecondLine = firstPointofSecondLine.Geometry.Y
     MessageBox.Show($"Value1: {yPositionofFirstPointofSecondLine}, Value2: {cornerPositionofFirstRect}")

Loop

'' Code here...

 

 

0 Likes
176 Views
2 Replies
Replies (2)
Message 2 of 3

C_Haines_ENG
Collaborator
Collaborator

It would help for others if you simplify this problem, instead of asking about a question halfway through a much larger script. Its hard for other people to troubleshoot if they don't have your full program, or if the program is too large in scale.

 

If you have set it to only move 1mm, you should check if the sketch moved the desired amount after each "MoveSketchOperations" object. The MsgBox() should pause the script after the move, so if its moving 2mm after one operation than you have a larger problem. 

 

 

Message 3 of 3

Mehmet_Fatih_Turker
Advocate
Advocate

 I just tried to keep as simple as possible. Its quite large scale project and considered as kind of intellectual property. I actually solved that by cutting (0, -0.1) to half so it will be like (0, -0.05) so now it moves selected sketch profile 1mm by 1 mm after this adjustment.

0 Likes