@@ -454,55 +454,69 @@ void relinkToBody (PartDesign::Feature *feature) {
454
454
455
455
bool isFeatureMovable (App::DocumentObject* const feat)
456
456
{
457
- if (!feat)
457
+ if (!feat) {
458
458
return false ;
459
+ }
459
460
460
- if (feat->isDerivedFrom <PartDesign::Feature>()) {
461
- auto prim = static_cast <PartDesign::Feature*>(feat);
461
+ if (auto prim = dynamic_cast <PartDesign::Feature*>(feat)) {
462
462
App::DocumentObject* bf = prim->BaseFeature .getValue ();
463
- if (bf)
463
+ if (bf) {
464
464
return false ;
465
+ }
465
466
}
466
467
467
- if (feat->isDerivedFrom <PartDesign::ProfileBased>()) {
468
- auto prim = static_cast <PartDesign::ProfileBased*>(feat);
468
+ if (auto prim = dynamic_cast <PartDesign::ProfileBased*>(feat)) {
469
469
auto sk = prim->getVerifiedSketch (true );
470
470
471
- if (!isFeatureMovable (sk))
471
+ if (!isFeatureMovable (sk)) {
472
472
return false ;
473
+ }
473
474
474
- if (auto prop = static_cast <App::PropertyLinkList*>(prim->getPropertyByName (" Sections" ))) {
475
- if (std::any_of (prop->getValues ().begin (), prop->getValues ().end (), [](App::DocumentObject* obj){
475
+ if (auto prop = dynamic_cast <App::PropertyLinkList*>(prim->getPropertyByName (" Sections" ))) {
476
+ if (std::any_of (prop->getValues ().begin (), prop->getValues ().end (), [](App::DocumentObject* obj) {
476
477
return !isFeatureMovable (obj);
477
- }))
478
+ })) {
478
479
return false ;
480
+ }
479
481
}
480
482
481
- if (auto prop = static_cast <App::PropertyLinkSub*>(prim->getPropertyByName (" ReferenceAxis" ))) {
483
+ if (auto prop = dynamic_cast <App::PropertyLinkSubList*>(prim->getPropertyByName (" Sections" ))) {
484
+ if (std::any_of (prop->getValues ().begin (), prop->getValues ().end (), [](App::DocumentObject* obj) {
485
+ return !isFeatureMovable (obj);
486
+ })) {
487
+ return false ;
488
+ }
489
+ }
490
+
491
+ if (auto prop = dynamic_cast <App::PropertyLinkSub*>(prim->getPropertyByName (" ReferenceAxis" ))) {
482
492
App::DocumentObject* axis = prop->getValue ();
483
- if (axis && !isFeatureMovable (axis))
493
+ if (axis && !isFeatureMovable (axis)) {
484
494
return false ;
495
+ }
485
496
}
486
497
487
- if (auto prop = static_cast <App::PropertyLinkSub*>(prim->getPropertyByName (" Spine" ))) {
498
+ if (auto prop = dynamic_cast <App::PropertyLinkSub*>(prim->getPropertyByName (" Spine" ))) {
488
499
App::DocumentObject* spine = prop->getValue ();
489
- if (spine && !isFeatureMovable (spine))
500
+ if (spine && !isFeatureMovable (spine)) {
490
501
return false ;
502
+ }
491
503
}
492
504
493
- if (auto prop = static_cast <App::PropertyLinkSub*>(prim->getPropertyByName (" AuxillerySpine" ))) {
505
+ if (auto prop = dynamic_cast <App::PropertyLinkSub*>(prim->getPropertyByName (" AuxillerySpine" ))) {
494
506
App::DocumentObject* auxSpine = prop->getValue ();
495
- if (auxSpine && !isFeatureMovable (auxSpine))
507
+ if (auxSpine && !isFeatureMovable (auxSpine)) {
496
508
return false ;
509
+ }
497
510
}
498
511
499
512
}
500
513
501
514
if (feat->hasExtension (Part::AttachExtension::getExtensionClassTypeId ())) {
502
515
auto attachable = feat->getExtensionByType <Part::AttachExtension>();
503
516
App::DocumentObject* support = attachable->AttachmentSupport .getValue ();
504
- if (support && !support->isDerivedFrom <App::OriginFeature>())
517
+ if (support && !support->isDerivedFrom <App::OriginFeature>()) {
505
518
return false ;
519
+ }
506
520
}
507
521
508
522
return true ;
@@ -512,34 +526,36 @@ std::vector<App::DocumentObject*> collectMovableDependencies(std::vector<App::Do
512
526
{
513
527
std::set<App::DocumentObject*> unique_objs;
514
528
515
- for (auto const &feat : features)
516
- {
517
-
529
+ for (auto const &feat : features) {
518
530
// Get sketches and datums from profile based features
519
- if (feat->isDerivedFrom <PartDesign::ProfileBased>()) {
520
- auto prim = static_cast <PartDesign::ProfileBased*>(feat);
531
+ if (auto prim = dynamic_cast <PartDesign::ProfileBased*>(feat)) {
521
532
Part::Part2DObject* sk = prim->getVerifiedSketch (true );
522
533
if (sk) {
523
- unique_objs.insert (static_cast <App::DocumentObject*>(sk));
534
+ unique_objs.insert (sk);
535
+ }
536
+ if (auto prop = dynamic_cast <App::PropertyLinkList*>(prim->getPropertyByName (" Sections" ))) {
537
+ for (App::DocumentObject* obj : prop->getValues ()) {
538
+ unique_objs.insert (obj);
539
+ }
524
540
}
525
- if (auto prop = static_cast <App::PropertyLinkList *>(prim->getPropertyByName (" Sections" ))) {
541
+ if (auto prop = dynamic_cast <App::PropertyLinkSubList *>(prim->getPropertyByName (" Sections" ))) {
526
542
for (App::DocumentObject* obj : prop->getValues ()) {
527
543
unique_objs.insert (obj);
528
544
}
529
545
}
530
- if (auto prop = static_cast <App::PropertyLinkSub*>(prim->getPropertyByName (" ReferenceAxis" ))) {
546
+ if (auto prop = dynamic_cast <App::PropertyLinkSub*>(prim->getPropertyByName (" ReferenceAxis" ))) {
531
547
App::DocumentObject* axis = prop->getValue ();
532
548
if (axis && !axis->isDerivedFrom <App::OriginFeature>()){
533
549
unique_objs.insert (axis);
534
550
}
535
551
}
536
- if (auto prop = static_cast <App::PropertyLinkSub*>(prim->getPropertyByName (" Spine" ))) {
552
+ if (auto prop = dynamic_cast <App::PropertyLinkSub*>(prim->getPropertyByName (" Spine" ))) {
537
553
App::DocumentObject* axis = prop->getValue ();
538
554
if (axis && !axis->isDerivedFrom <App::OriginFeature>()){
539
555
unique_objs.insert (axis);
540
556
}
541
557
}
542
- if (auto prop = static_cast <App::PropertyLinkSub*>(prim->getPropertyByName (" AuxillerySpine" ))) {
558
+ if (auto prop = dynamic_cast <App::PropertyLinkSub*>(prim->getPropertyByName (" AuxillerySpine" ))) {
543
559
App::DocumentObject* axis = prop->getValue ();
544
560
if (axis && !axis->isDerivedFrom <App::OriginFeature>()){
545
561
unique_objs.insert (axis);
0 commit comments