Selecting Paperspace entities

I seem to have posted a topic on paperspace and layouts before and I'm still a bit puzzled:A drawing contains a few special blocks named *Model_Space, *Paper_Space and in case of more than one layout *Paper_Space0, *Paper_Space1, etc.Each layout tab is associated with one of these blocks by its 'block' property, were the block of the ActiveLayout is named *Paper_space. When switching to and other layout in the drawing, the blocknames of the new selected and previously layouts are swapped so the block of the newly activated layout is now called *Paper_Space. The Model tab is associated with the *Model_Space block.When I use a ((V)BA) selectionset to select, say, all lines from Modelspace I asume the *Modelspace block is searched for me.Code below selects lines from Paperspace.Now lets say I have two PsLayouts in a drawing and I draw 1 line on Layout1 and two lines on Layout2.I make Layout1 my ActiveLayout and run the macro. The result is a count of three lines, so aparently all the *Paper_space? blocks were queried, not the sole active Paper_Space.. I see the same behaviour in Acad2009 so that's how it's ment to be?If I have copied a chart layout a few times to different tabs and I want so access, say, the title block of a certain layout (through a selection set), how do I this?TIA,Arno van EeuwenPrivate Sub CountPsLines() Dim Sset As AcadSelectionSet Dim FilterType(0 To 1) As Integer Dim FilterData(0 To 1) As Variant Dim SingleLayout As AcadLayout FilterType(0) = 0: FilterData(0) = "LINE" ' lines FilterType(1) = 67: FilterData(1) = 1 ' paperspace On Local Error Resume Next ThisDrawing.SelectionSets.Item("Temp").Delete On Local Error GoTo 0 Set Sset = ThisDrawing.SelectionSets.Add("Temp") ThisDrawing.ActiveLayout = ThisDrawing.Layouts.Item("Layout1") Sset.Select acSelectionSetAll, , , FilterType, FilterData Call MsgBox(ThisDrawing.ActiveLayout.Block.name, , "Lines:" + Format(Sset.Count)) For Each SingleLayout In ThisDrawing.Layouts MsgBox SingleLayout.Block.name, , SingleLayout.name Next End Sub

Comments

  • Here is my effort to loop through the Paperspaces and select only the lines for that Layout.

    Sub LoopLayouts()Dim myLayout As AcadLayoutFor Each myLayout In ThisDrawing.Layouts If myLayout.Name <> "Model" Then MsgBox "In " & myLayout.Name & " there are " & JFSSetObjects(myLayout.Name).Count & " Lines" End IfNextEnd Sub
    Private Function JFSSetObjects(JFLayout As String) As AcadSelectionSet' This Function returns a selection set of all Lines in a PaperSpace LayoutDim GPC(3) As IntegerDim GPV(3) As Variant' if the SSName exists then clear itDim strSSName As StringstrSSName = "SSName"For Each JFSSetObjects In ThisDrawing.SelectionSets If JFSSetObjects.Name = strSSName Then JFSSetObjects.DeleteNext'Make empty selection SetSet JFSSetObjects = ThisDrawing.SelectionSets.Add(strSSName)' set filters for Layout and Line to be included in the SelectionSetGPC(0) = -4GPV(0) = ""' obtain all filtered objectsJFSSetObjects.Select acSelectionSetAll, , , GPC, GPVEnd Function
  • It looks like the Function got corrupted in the code tags so here it is again without code tags:Private Function JFSSetObjects(JFLayout As String) As AcadSelectionSet' This Function returns a selection set of all Lines in a PaperSpace LayoutDim GPC(3) As IntegerDim GPV(3) As Variant' if the SSName exists then clear itDim strSSName As StringstrSSName = "SSName"For Each JFSSetObjects In ThisDrawing.SelectionSets If JFSSetObjects.Name = strSSName Then JFSSetObjects.DeleteNext'Make empty selection SetSet JFSSetObjects = ThisDrawing.SelectionSets.Add(strSSName)' set filters for Layout and Line to be included in the SelectionSetGPC(0) = -4GPV(0) = "<and"GPC(1) = 410GPV(1) = JFLayoutGPC(2) = 0GPV(2) = "Line"GPC(3) = -4GPV(3) = "and>"' obtain all filtered objectsJFSSetObjects.Select acSelectionSetAll, , , GPC, GPVEnd Function

  • Hm.........Still Corrupting! must be a tag on the forum that gets recognised.so GPV(0) = "<and" should be GPV(0) = "Less Than Sign and" to counter balance the GPV(3) = "and Greater than sign"So GPC(1) = 410

  • Bang on the spot John!The GPC(1)= 410 with GPV(1)=Layoutname does exactly what I need.Thanks,Arno

This discussion has been closed.