Find meshes in groups

How to remove from selection objects that can contain meshes inside group, or inside powerclip?

dim h as shape, s as shape

ActiveLayer.Shapes.All.CreateSelection

For Each s In ActiveSelection.Shapes

'Set h = s.Shapes.FindShapes(Type:=cdrMeshFillShape) 'something like this, but this not working.
'If Not h Is Nothing Then s.RemoveFromSelection

next

Parents
No Data
Reply
  • For questions like this I would recommend the Developer Area. (Forums - Developer Area - CorelDRAW Community)

    Here is a function that will dig into Groups and PowerClips. You can use it to find your MeshFillShapes. 

    Sub TestFindAllShapes()
        Dim s As Shape
        
        ActiveLayer.Shapes.All.CreateSelection
        
        For Each s In FindAllShapes.Shapes.FindShapes(Type:=cdrMeshFillShape)
            If Not s.PowerClipParent Is Nothing Then
                s.PowerClipParent.RemoveFromSelection
            ElseIf Not s.ParentGroup Is Nothing Then
                s.ParentGroup.RemoveFromSelection
            Else
                s.RemoveFromSelection
            End If
        Next s
    End Sub
    
    Function FindAllShapes() As ShapeRange
        Dim s As Shape
        Dim sr As ShapeRange
        Dim srAll As New ShapeRange, srPowerClipped As New ShapeRange
    
        If ActiveSelection.Shapes.Count > 0 Then
            Set sr = ActiveSelection.Shapes.FindShapes()
        Else
            Set sr = ActivePage.Shapes.FindShapes()
        End If
        
        Do
            For Each s In sr.Shapes.FindShapes(Query:="!@com.powerclip.IsNull")
                srPowerClipped.AddRange s.PowerClip.Shapes.FindShapes()
            Next s
            
            srAll.AddRange sr
            sr.RemoveAll
            sr.AddRange srPowerClipped
            srPowerClipped.RemoveAll
        Loop Until sr.Count = 0
        
        Set FindAllShapes = srAll
    End Function
    

    Happy coding, 

    -Shelby

Children
No Data