-
Notifications
You must be signed in to change notification settings - Fork 563
Create a POINT_N_COPY from a Vector? #718
Description
I'm writing code to import IDF files. It's working ok, but all the points are regular points created by calling one of:
SS.GW.AddRequest(Request::Type::LINE_SEGMENT, /*rememberForUndo=*/false);
SS.GW.AddRequest(Request::Type::ARC_OF_CIRCLE, /*rememberForUndo=*/false);
SS.GW.AddRequest(Request::Type::CIRCLE, /*rememberForUndo=*/false);
The problem with that is each point has 3 DoF in the solver and that function not only creates a line entity, it creates two point entities. I'd rather do two things:
- Create lines and points separately so adjoining lines can share a point via the same handle (hEntity)
- Make the points of type POINT_N_COPY and just set their numeric coordinates directly
I've been trying to make these new functions work:
hEntity newFixedPoint(Vector p) {
Entity point = {};
point.type = Entity::Type::POINT_N_COPY;
point.numPoint = p;
point.construction = false;
// point.style = something;
point.group = SS.GW.activeGroup;
point.h = SK.entity.AddAndAssignId(&point);
return point.h;
}
hEntity newFixedLine(hEntity p0, hEntity p1) {
Entity line = {};
line.type = Entity::Type::LINE_SEGMENT;
line.point[0] = p0;
line.point[1] = p1;
line.construction = false;
// line.style = something GetStyle();
line.group = SS.GW.activeGroup;
line.h = SK.entity.AddAndAssignId(&line);
return line.h;
}
With those functions I want to change my line creation code like this: (the commented lines work)
Vector p0 = Vector::From(x1, y1, 0.0);
Vector p1 = Vector::From(x2, y2, 0.0);
hEntity pa = newFixedPoint(p0);
hEntity pb = newFixedPoint(p1);
newFixedLine(pa,pb);
// hRequest hr = SS.GW.AddRequest(Request::Type::LINE_SEGMENT, /*rememberForUndo=*/false);
// SK.GetEntity(hr.entity(1))->PointForceTo(p0);
// SK.GetEntity(hr.entity(2))->PointForceTo(p1);
The existing way works and is similar to DXF import, but it creates disconnected entities. DXF import constrains coincident points, but I'd rather just use the same points and have zero DoF by using POINT_N_COPY type. I can make lines share points after this direct replacement is working. Also, where can I get the correct style from? It seems like every place in the code that sets a style member copies another one which I don't have here.