Jump to content
TunzaGibbo

lisp commands

Recommended Posts

TunzaGibbo

I want my lisp file to insert a block in a certain way.

After "_insert" I would like the program to go to a specific folder where I keep my blocks.

This code works fine if I have a block name where the question marks are. Is there some code I can enter where the question marks are to get the dialogue box?

(command "_insert" "??????????" pause 1 "" 0 )

 

Share this post


Link to post
Share on other sites
Lee Mac

Here is one option:

(if (setq blk (getfiled "Select block" "" "dwg" 16))
    (command "_.-insert" blk "_S" 1 "_R" 0 "\\")
)

 

Share this post


Link to post
Share on other sites
TunzaGibbo

Thank you Lee

(command "_insert" "C:\\Users\\Tony Clean Install\\#Advance\\Blocks\\Cameras\\Camera HD Detail.dwg" pause 1 "" 0 )

if I was to use this line (which works well) How could I incorporate in this line the ability to explode the block

 

regards

 

Tony

 

 

 

Share this post


Link to post
Share on other sites
asos2000

(if (and
    (vl-cmdf "_insert" "C:\\Users\\Tony Clean Install\\#Advance\\Blocks\\Cameras\\Camera HD Detail.dwg" pause 1 "" 0 )        ; inser block
    (setq CMHDD (ssget "x" '((0 . "INSERT") (2 . "Camera HD Detail"))))
    )    
    (progn
      (vl-cmdf "_.EXPLODE" CMHDD "")
      (vl-cmdf "_.-purge" "blocks" "Camera HD Detail" "n")
      ))

Share this post


Link to post
Share on other sites
BIGAL

Why not explode entlast ! 

  • Like 1

Share this post


Link to post
Share on other sites
asos2000
1 hour ago, BIGAL said:

Why not explode entlast ! 

👍 Yes 

Share this post


Link to post
Share on other sites
Lee Mac

Alternatively, you could use something like this:

(setq pth "C:\\Users\\Tony Clean Install\\#Advance\\Blocks\\Cameras\\Camera HD Detail.dwg"
      blk (vl-filename-base pth)
)
(if (or (tblsearch "block" blk)
        (and
            (or (findfile pth)
                (prompt (strcat "\n" pth " not found."))
            )
            (or (progn
                    (command "_.-insert" pth nil)
                    (tblsearch "block" blk)
                )
                (prompt (strcat "\n" blk " could not be defined."))
            )
        )
    )
    (command "_.-insert" (strcat "*" blk) "\\" 1 0)
)

 

  • Like 1

Share this post


Link to post
Share on other sites
TunzaGibbo

Thankyou everyone for your contributions.

This is what I am finally using and it works perfect.

(command "_insert" "Camera HD Detail.dwg" pause 1 "" 0)(setq blex (entlast))(command "_explode" blex)

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×