DXF: do not ignore the setting that controls importing paper layouts

This commit is contained in:
Furgo
2025-06-11 14:16:22 +02:00
committed by Yorik van Havre
parent fea582dc10
commit f3a4b9de78
2 changed files with 41 additions and 0 deletions

View File

@@ -207,6 +207,10 @@ void ImpExpDxfRead::OnReadLine(const Base::Vector3d& start,
const Base::Vector3d& end,
bool /*hidden*/)
{
if (shouldSkipEntity()) {
return;
}
gp_Pnt p0 = makePoint(start);
gp_Pnt p1 = makePoint(end);
if (p0.IsEqual(p1, 0.00000001)) {
@@ -219,6 +223,10 @@ void ImpExpDxfRead::OnReadLine(const Base::Vector3d& start,
void ImpExpDxfRead::OnReadPoint(const Base::Vector3d& start)
{
if (shouldSkipEntity()) {
return;
}
Collector->AddObject(BRepBuilderAPI_MakeVertex(makePoint(start)).Vertex(), "Point");
}
@@ -229,6 +237,10 @@ void ImpExpDxfRead::OnReadArc(const Base::Vector3d& start,
bool dir,
bool /*hidden*/)
{
if (shouldSkipEntity()) {
return;
}
gp_Pnt p0 = makePoint(start);
gp_Pnt p1 = makePoint(end);
gp_Dir up(0, 0, 1);
@@ -251,6 +263,10 @@ void ImpExpDxfRead::OnReadCircle(const Base::Vector3d& start,
bool dir,
bool /*hidden*/)
{
if (shouldSkipEntity()) {
return;
}
gp_Pnt p0 = makePoint(start);
gp_Dir up(0, 0, 1);
if (!dir) {
@@ -393,6 +409,10 @@ void ImpExpDxfRead::OnReadEllipse(const Base::Vector3d& center,
bool dir)
// NOLINTEND(bugprone-easily-swappable-parameters)
{
if (shouldSkipEntity()) {
return;
}
gp_Dir up(0, 0, 1);
if (!dir) {
up = -up;
@@ -414,6 +434,10 @@ void ImpExpDxfRead::OnReadText(const Base::Vector3d& point,
const std::string& text,
const double rotation)
{
if (shouldSkipEntity()) {
return;
}
// Note that our parameters do not contain all the information needed to properly orient the
// text. As a result the text will always appear on the XY plane
if (m_importAnnotations) {
@@ -454,6 +478,10 @@ void ImpExpDxfRead::OnReadInsert(const Base::Vector3d& point,
const std::string& name,
double rotation)
{
if (shouldSkipEntity()) {
return;
}
Collector->AddInsert(point, scale, name, rotation);
}
void ImpExpDxfRead::ExpandInsert(const std::string& name,
@@ -534,6 +562,10 @@ void ImpExpDxfRead::OnReadDimension(const Base::Vector3d& start,
const Base::Vector3d& point,
double /*rotation*/)
{
if (shouldSkipEntity()) {
return;
}
if (m_importAnnotations) {
auto makeDimension =
[this, start, end, point](const Base::Matrix4D& transform) -> App::FeaturePython* {
@@ -576,6 +608,10 @@ void ImpExpDxfRead::OnReadDimension(const Base::Vector3d& start,
}
void ImpExpDxfRead::OnReadPolyline(std::list<VertexInfo>& vertices, int flags)
{
if (shouldSkipEntity()) {
return;
}
std::map<CDxfRead::CommonEntityAttributes, std::list<TopoDS_Shape>> ShapesToCombine;
{
// TODO: Currently ExpandPolyline calls OnReadArc etc to generate the pieces, and these

View File

@@ -108,6 +108,11 @@ public:
void setOptions();
private:
bool shouldSkipEntity() const
{
// This entity is in paper space, and the user setting says to ignore it.
return !m_importPaperSpaceEntities && m_entityAttributes.m_paperSpace;
}
static gp_Pnt makePoint(const Base::Vector3d& point3d)
{
return {point3d.x, point3d.y, point3d.z};