diff --git a/pcbnew/pcbexpr_functions.cpp b/pcbnew/pcbexpr_functions.cpp index e985ffbbf7..ebbac4fb77 100644 --- a/pcbnew/pcbexpr_functions.cpp +++ b/pcbnew/pcbexpr_functions.cpp @@ -873,7 +873,10 @@ static void memberOfSheetFunc( LIBEVAL::CONTEXT* aCtx, void* self ) result->SetDeferredEval( [item, arg]() -> double { - FOOTPRINT* fp = item->GetParentFootprint(); + FOOTPRINT* fp = dyn_cast( item ); + + if( !fp ) + fp = item->GetParentFootprint(); if( !fp ) return 0.0; @@ -882,7 +885,7 @@ static void memberOfSheetFunc( LIBEVAL::CONTEXT* aCtx, void* self ) return 1.0; if( ( arg->AsString().Matches( wxT( "/" ) ) || arg->AsString().IsEmpty() ) - && fp->GetSheetname().IsEmpty() ) + && fp->GetSheetname() == wxT( "Root" ) ) { return 1.0; }