Jump to content

Using local variables with open command script


Shady_Potato

Recommended Posts

Greetings,

 

Im working on a test lisp to see if I can automate binding an existing xref & converting a bounded block reference back into an xref. while I was able to automate bind, I realized the express tool (-blocktoxref) is incompatible with lisp as it cant seem to find the command. Then I created a script that allows me to set up an open command, but I cant seem to use my local variables (BLKNAME & NEWFILEPATH) with the script command. So my question is, Is it possible to write a script via lisp? and if so how?

 

(defun c:ws_Layer_copy ()
(vl-load-com) 
(setq en (ssget "x" '((0 . "insert") (8 . "XREF - ELECTRICAL - 1"))))
(setq ent (ssname en 0))
(setq EN (entget ent))
(setq layno (vl-string-left-trim "XREF - ELECTRICAL - " (cdr(assoc 8 EN))))
(setq dwgpath (getvar "dwgprefix"))  
(setq dwgname (getvar "dwgname"))
(setq nametrim (vl-string-right-trim "HVAC LAYOUT.dwg" dwgname))
(if (= layno "1")
 (setq layname "1st")
)
 (if (= layno "2")
 (setq layname "2nd")
)
 (if (= layno "3")
 (setq layname "3rd")
)
 (if (= layno "4")
 (setq layname "4th")
)
 (if (= layno "5")
 (setq layname "5th")
)
(setq newfilepath (strcat nametrim layname " Floor Electrical" ))
(setq blkname (vl-string-left-trim dwgpath newfilepath))  
(command "-xref" "bind" newfilepath )
;----------------------------------------------------------------------
(command "script" "blocktoxref.scr" )  
)

Link to comment
Share on other sites

A lot of the express tools can be accessed via lisp you need though to look in the lisp code for express 2 come to mind extrim & Tcircle can be accessed but not by those names. Will try to find in lisp.

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...