Jump to content

bloody autoLISP.. Help


leolill

Recommended Posts

Hi guys and thanks in advance for any help.

 

I have an autolisp called bigbang.lsp.

(defun C:BIGBANG ( / )

;; First we busrt everything a few times...

(setq timesexplode 10) ;Change number to suit your needs

(repeat timesexplode

(setvar "qaflags" 1)

(command ".explode" (ssget "_X" ) "")

(setvar "qaflags" 0)

)

;define allobjects

(setq allobjects (ssget "_X" ))

;; Now set everything by layer...

(command "_SetByLayer" allobjects "" "Yes" "Yes")

;; Set everything to layer 0

(command "_CHANGE" allobjects "" "Properties" "Layer" "0" "")

;; Set current layer 0

(setvar "CLAYER" "0")

;; Purge the drawing

(command "-Purge" "All" "*" "No")

(princ)

)

(princ)

I load it through the cui and works great if I go to model space first.

But stuffed if I can get it to go to model space before it starts, only does the layout1 that is current tab.


Also wanted to delete all hatches and mtext, but can't get that to work. Asks for select internal point;

(defun c:delete_all_hatches ()

; Delete all hatches

(command "_-hatch" "DELETE" "ALL" )

(princ "\nAll hatches deleted!")

)

First delve into autolisp, its killing me. Wanted to put it in a script or something to run on a list of dwg files. I have 98.

Any advice, I'll love you forever!

Cheers, Lenny

Edited by SLW210
Added Code Tags!
Link to comment
Share on other sites

This should take you to model space

 

(setvar 'ctab "model" )

 

 

Going to layout1 or other paperspaces  if you need to, you might want to confirm that the name exists, getting the list of paperspaces from (layoutlist) function

 

To delete hatches I would usually select them with an ssget and delete the selection set, selection set gives the option for more filtering - could for example do all hatches on layer 0 that are coloured red

 

 

(defun c:deletehatched ( / MySS )
  (setq MySS (ssget "_X" '((0 . "HATCH"))))
  (command "erase" MySS "")
)

 

can use a similar method for mtexts,

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...