Jump to content

Combining two lisp's


wayne murphy

Recommended Posts

Hi

I am new to this forum. I have been using lisp for a while, but not great at writing complex ones. In this case I want to combine two lisps.

The first opens a template, the second executes a query from a drawing attached to the template, and unattaches the file once complete. I would like to have these in one command so it will open the drawing , execute the query, unattach, then zoom to extents. They work well seperatly, but would be a time saver and save my users steps if combined. I have a swore head from beating against wall, I don't know what I am missing, but would appreciate any segestions or help.

 

Lisp 1

(defun c:openD_NS&PEI nil
(vla-open (vla-get-documents (vlax-get-acad-object))
           "V:\\symbol\\smt\\Construction_blocks\\1-01_D_SIZE_CONSTRUCTION_PACKAGE_TEMPLATE - Nova Scotia.dwg":vlax-false))

 

 

Lisp 2

(defun c:executequery (/)(ade_errsetlevel 2)(ade_qryexecute) (foreach x (ade_dslist) (ade_dsdetach x))(command ".zoom" "e")))

Edited by wayne murphy
Requested by admin
Link to comment
Share on other sites

Maybe something like this but save as a script SCR scripts can handle the open dwg and keep going.

 

(defun c:OpenD_NS&PEI nil
(vla-open (vla-get-documents (vlax-get-acad-object))
"V:\\symbol\\smt\\Construction_blocks\\1-01_D_SIZE_CONSTRUCTION_PACKAGE_TEMPLATE - Nova Scotia.dwg":vlax-false)
(ade_errsetlevel 2)
(ade_qryexecute) 
(foreach x (ade_dslist) (ade_dsdetach x))(command ".zoom" "e"))
)

Link to comment
Share on other sites

I had already tried that and it did not work. Loaded the template, but stoped there.

I found the following lisp that worked better for opening the template:

(defun c:open11x17_NS&PEI (/ cd vgad vgao vgd)
 (vl-load-com)
 (setq vgao (vlax-get-acad-object))
 (setq vgad (vla-get-activedocument vgao))
 (setq vgd (vla-get-documents vgao))
 (setq cd "V:/symbol/smt/Construction_blocks/1-0_11x17_SIZE_CONSTRUCTION_PACKAGE_TEMPLATE - Nova Scotia.dwg") 
 (if
   (= 0 (getvar "SDI"))
   (vla-activate (vla-open vgd cd))                               ; if sdi = 0
   (vla-sendcommand vgad (strcat "(command \"_open\")\n" cd "\n")(ade_errsetlevel 2)(ade_qryexecute) (foreach x (ade_dslist) (ade_dsdetach x))(command ".zoom" "e")); if sdi = 1
   )                              ; if
 (princ)
 )

 

and would still like it to run this lisp once the template is open

(defun c:executequery (/)(ade_errsetlevel 2)(ade_qryexecute) (foreach x (ade_dslist) (ade_dsdetach x))(command ".zoom" "e")))

Link to comment
Share on other sites

If you want it to run automatically then just add the lisp to ACADDOC.lsp or add via Appload to your history so it autoloads. Make sure you add an extra line outside the defun (c:executequery) and it will run but also allow you to do manually.

Link to comment
Share on other sites

  • 3 months later...

Thanks for the solution. This worked well for me. I placed the code shown below in the acaddoc and it worked. however I would like to only detach a specific file that is attached to my template. I have tried putting the path in the lisp (replaced the x), but it is not detaching it, nor is it giving me errors or any other problems. How would I specify a specific file. The line below is what I have tried.

(ade_errsetlevel 2)(ade_qryexecute) (foreach x (ade_dslist) (ade_dsdetach C:\\Temp folder extract from spatial\\File saved from Spatial.dwg))(command ".zoom" "e")

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