How to Exclude Model or Layouts with filters when exporting a PDF from an AutoCAD drawing

To keep specific Model or Layout pages from being exported you can define filters by Name, to do this you can use Operators such as -like, -eq -notlike. You can also use Wildcards with *, when using wildcards there could be written anything before or after the word you search for, depends on where you put the *. You can also put it before and after the word. In the attached sample script i'm using "House*" to exclude the word "House" but also words like "Housekeeper" are excluded because of the wildcard after the word.

Changing the $ExcludeName variable will result in every Layout with the same name being excluded. In the Line 

$sheetsToRemove = $sheets | Where { $_.Layout -like "$ExcludeName" }
You can define the operator.

Examples

Excludes every Layout that has the word House in it like "Housekeeper" or "Doghouse" because of the * before and after the word

$ExcludeName = "*House*"
Excludes just Layouts that have something before the word House like Doghouse, Housekeeper is not excluded
$ExcludeName = "*House"
Excludes just Layout that have exactly the same name
$sheetsToRemove = $sheets | Where { $_.Layout -eq "$ExcludeName" }
Excludes Layouts that don't have the same name
$sheetsToRemove = $sheets | Where { $_.Layout -notlike "$ExcludeName" }

See Also

Downloads