Author Topic: Lisp to clear all but Continuous & ByLayer  (Read 2047 times)

0 Members and 1 Guest are viewing this topic.

TR

  • Guest
Lisp to clear all but Continuous & ByLayer
« on: June 24, 2005, 09:27:41 AM »
Let me start off by saying I don't know lisp and at this point I really don't have time to mess with learning it. Basically that translates to I'm looking for a "free fish".

I constantly download dxf files from Hoffman Enclosures to place in my control panel layout. This works out well for me except for the fact that they include tons of hidden and phantom lines which I have to erase. With that being said can anyone whip me up a quick and dirty lisp routine that will allow me to select a group of objects and it will erase everything that's not either bylayer or continuous linetypes?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Lisp to clear all but Continuous & ByLayer
« Reply #1 on: June 24, 2005, 09:58:47 AM »
try filter ..

i.e.

Command: Erase
Select objects: 'filter
Then follow the prompts

Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

daron

  • Guest
Lisp to clear all but Continuous & ByLayer
« Reply #2 on: June 24, 2005, 10:05:33 AM »
Don't forget that typing P will select everything according to the filters params.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Lisp to clear all but Continuous & ByLayer
« Reply #3 on: June 24, 2005, 10:09:32 AM »
Or I just threw together a vba macro that will do it.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Lisp to clear all but Continuous & ByLayer
« Reply #4 on: June 24, 2005, 10:10:20 AM »
Code: [Select]
Option Explicit

Public Sub DelEverythingNotBylayer()

Dim objSelected As Object
Dim objSelSet As AcadSelectionSet
Dim N As Integer

On Error Resume Next

If ThisDrawing.SelectionSets.Count > 0 Then
    For N = 0 To ThisDrawing.SelectionSets.Count - 1
        If ThisDrawing.SelectionSets.Item(N).Name = "EBL" Then
        ThisDrawing.SelectionSets("EBL").Delete
        End If
    Next N
End If

Set objSelSet = ThisDrawing.SelectionSets.Add("EBL")
objSelSet.Select acSelectionSetAll

For Each objSelected In objSelSet
    If objSelected.Linetype = "ByLayer" Then
    objSelected.Update
    ElseIf objSelected.Linetype = "Continuous" Then
    objSelected.Update
    Else
    objSelected.Delete
End If
Next


ThisDrawing.SelectionSets.Item("EBL").Delete
ThisDrawing.Application.Update
Exit_Here:
Exit Sub
End Sub
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

TR

  • Guest
Lisp to clear all but Continuous & ByLayer
« Reply #5 on: June 24, 2005, 10:25:13 AM »
Thanks for all the info.

I'll have to remember filter for future use.

That vba macro looks nice, thanks. I tried whipping something up real quick in vba but I gave up because I despise selection sets and too much Jim Beam last night.

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Lisp to clear all but Continuous & ByLayer
« Reply #6 on: June 24, 2005, 01:26:06 PM »
Quote from: Tim Riley
I tried whipping something up real quick in vba but I gave up because I despise selection sets
Actually, I don't see a need for the select set in this case. A loop through the Blocks collection and a loop through each block's entities would do the same thing and more. The 'more' being that it will remove those items from block defs, too. If you don't want to affect normal block defs, then loop through the Layouts collection and obtain the Layout's block to loop through.