Error using sketch3d for lines.

Error using sketch3d for lines.

r.ziethen
Participant Participant
184 Views
1 Reply
Message 1 of 2

Error using sketch3d for lines.

r.ziethen
Participant
Participant

Connecting 2 Sketch3D-Lines there arise an error, becuase between the two lines the API puts an circle with an radius of 5 mm.


for (i = 0; i < kante[fk_nr].Count;i++)// Program.Fertig_Block.fahrkante[fk_nr].Count; i++)
{
Geometric g = new Geometric(kante[fk_nr][i]);// Program.Fertig_Block.fahrkante[fk_nr][i]);
Program.fp.Write("\nfk: {13}\n{9}/{6}. Kurv: P= {0:f12},{1:f12},{11} wink: {2} Kr {3} Lg: {4} Typ: {5}\n E= {7:f12},{8:f12},{12} lg: {10}\n",
g.Startpoint.X, g.Startpoint.Y, g.Startpoint.AngleXY, g.Startpoint.Curvature, g.Length, g.Name, fk_nr, g.Endpoint.X, g.Endpoint.Y, i, g.Endpoint.CurrentLength, g.Startpoint.Z, g.Endpoint.Z, fk_nr);
Program.fp.Flush();
// Create a 3D sketch
if (i == 0)
{
if (g.Name.StartsWith("Ge")) //g.Name.StartsWith("Gerade")
{
gerade = oSketch3d.SketchLines3D.AddByTwoPoints(tg0.CreatePoint(g.Startpoint.X / 10, g.Startpoint.Y / 10, hh / 10), tg0.CreatePoint(g.Endpoint.X / 10, g.Endpoint.Y / 10, hh / 10));
Program.fp.Write("GA i= {0}. Kurv: P= {1:f12},{2:f12}\n E= {3:f12},{4:f12}\n", i,
g.Startpoint.X, g.Startpoint.Y, g.Endpoint.X, g.Endpoint.Y);
Program.fp.Write("GB i= {0}. Kurv: P= {1:f12},{2:f12}\n E= {3:f12},{4:f12}\n", i,
gerade.EndSketchPoint.Geometry.X, gerade.EndSketchPoint.Geometry.Y, g.Endpoint.X, g.Endpoint.Y);
Program.fp.Flush();
last_el = 0;
}
else
{
radius = 1 / g.Startpoint.Curvature;
rich = true; if (radius < 0) rich = false;
mitte[0] = g.Startpoint.X + radius * Math.Cos(g.Startpoint.AngleXY + Math.PI / 2);
mitte[1] = g.Startpoint.Y + radius * Math.Sin(g.Startpoint.AngleXY + Math.PI / 2);
bogen = oSketch3d.SketchArcs3D.AddByCenterStartEndPoint(
tg0.CreatePoint(mitte[0] / 10, mitte[1] / 10, mitte[2] / 10),
tg0.CreatePoint(g.Startpoint.X / 10, g.Startpoint.Y / 10, hh / 10),
tg0.CreatePoint(g.Endpoint.X / 10, g.Endpoint.Y / 10, hh / 10), x, rich);
rich_alt = rich;
last_el = 1;
}
}
else
{
if (g.Name.StartsWith("Ge")) //g.Name.StartsWith("Gerade")
{
if (last_el == 0)
{
gerade = oSketch3d.SketchLines3D.AddByTwoPoints(gerade.EndSketchPoint, tg0.CreatePoint(g.Endpoint.X / 10, g.Endpoint.Y / 10, hh / 10));
Program.fp.Write("A i= {0}. Kurv: P= {1:f12},{2:f12}\n E= {3:f12},{4:f12}\n", i,
g.Startpoint.X, g.Startpoint.Y, g.Endpoint.X, g.Endpoint.Y);
Program.fp.Write("B i= {0}. Kurv: P= {1:f12},{2:f12}\n E= {3:f12},{4:f12}\n", i,
gerade.EndSketchPoint.Geometry.X, gerade.EndSketchPoint.Geometry.Y, g.Endpoint.X, g.Endpoint.Y);
Program.fp.Flush();
}
else
{
if (rich_alt == true)
gerade = oSketch3d.SketchLines3D.AddByTwoPoints(bogen.EndSketchPoint, tg0.CreatePoint(g.Endpoint.X / 10, g.Endpoint.Y / 10, hh / 10));
else
gerade = oSketch3d.SketchLines3D.AddByTwoPoints(bogen.StartSketchPoint, tg0.CreatePoint(g.Endpoint.X / 10, g.Endpoint.Y / 10, hh / 10));
}
last_el = 0;
}
else
{
double sigrad = 1;
if (g.Startpoint.Curvature < 0) sigrad = -1;
radius = 1 / g.Startpoint.Curvature;
rich = true; if (radius < 0) rich = false;
mitte[0] = g.Startpoint.X + Math.Abs(radius)* Math.Cos(g.Startpoint.AngleXY +sigrad* Math.PI / 2);
mitte[1] = g.Startpoint.Y + Math.Abs(radius) * Math.Sin(g.Startpoint.AngleXY + sigrad * Math.PI / 2);
if (last_el == 0)
bogen = oSketch3d.SketchArcs3D.AddByCenterStartEndPoint(
tg0.CreatePoint(mitte[0] / 10, mitte[1] / 10, hh / 10), gerade.EndSketchPoint, tg0.CreatePoint(g.Endpoint.X / 10, g.Endpoint.Y / 10, hh / 10), x, rich);
else
{
if (rich_alt == true)
bogen = oSketch3d.SketchArcs3D.AddByCenterStartEndPoint(tg0.CreatePoint(mitte[0] / 10, mitte[1] / 10, hh / 10), bogen.EndSketchPoint, tg0.CreatePoint(g.Endpoint.X / 10, g.Endpoint.Y / 10, hh / 10), x, rich);
else
bogen = oSketch3d.SketchArcs3D.AddByCenterStartEndPoint(tg0.CreatePoint(mitte[0] / 10, mitte[1] / 10, hh / 10), bogen.StartSketchPoint, tg0.CreatePoint(g.Endpoint.X / 10, g.Endpoint.Y / 10, hh / 10), x, rich);
}
rich_alt = rich;
last_el = 1;
}
}
Inventor_class.partDoc_fak_12.Update();
}

 

 


fk: 0
0/0. Kurv: P= -1993.225810143040,164.471771641276,0 wink: -0.0825790859380346 Kr 0 Lg: 200 Typ: Gerade
E= -1793.907353250160,147.974719121410,0 lg: 200
GA i= 0. Kurv: P= -1993.225810143040,164.471771641276
E= -1793.907353250160,147.974719121410
GB i= 0. Kurv: P= -179.390735325016, 14.797471912141
E= -1793.907353250160,147.974719121410
fk: 0
1/0. Kurv : P= -1793.907353250160,147.974719121410,0 wink: -0.0820230240383492 Kr 0 Lg: 900.0001 Typ: Gerade
E= -896.933056017936, 74.236736339399,0 lg: 1100.0001
A i= 1. Kurv: P= -1793.907353250160,147.974719121410
E= -896.933056017936, 74.236736339399
B i= 1. Kurv: P= -89.693305601794, 7.423673633940
E= -896.933056017936, 74.236736339399

0 Likes
185 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor

Hi @r.ziethen.  Just based on your initial statements, and without even reviewing your code, if the problem is because of the automatic bends / radii, then there is a way to turn that off, if needed.  Within Inventor's application options, on the Sketch tab, there is a setting under the "3D Sketch" heading, named "Auto-bend with 3D line creation".  You can uncheck that checkbox.  Then, if you just want to control the radius of that auto bend, you can go into the document settings (Tools tab, Options panel), to the Sketch tab, and there is a setting under the "3D Sketch" heading, named "Auto-Bend Radius" that you can change.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes