Jump to content

LSP: Substitute out 'vl-filename-base' from a LISP command


Recommended Posts

Posted

Hi,

 

I'm working on a LISP that in part needs to grab the filename (without extension) for a command - I managed to do this using 'vl-filename-base' but since it needs to run in acoreconsole it can't use anything from the VL Library. Is there any way to either remove ".dwg" or remove the last 4 characters from a string in only vanilla LISP?


Here's what I've got so far
 

(defun C:PlotToLocation (/ filename)

      (vl-load-com)

    (setvar "cmdecho" 0)


      (setq filename (vl-filename-base (getvar 'dwgname)))
      (setq filename (strcat "A:\\X\\Y\\" (vl-filename-base (getvar 'dwgname))".pdf"))

 

This sets the filename to "A:\X\Y\filename.pdf"

 

I can currently get "A:\X\Y\filename.dwg.pdf" but since the PDFs have to follow a naming standard, I need a way to remove the ".dwg".

Posted
50 minutes ago, rlx said:

(cadr (fnsplitl (getvar 'dwgname)))

 

HAHAHA ... cross posted at Adesk forum last Friday.

 

  • Funny 1
Posted

Awesome, thanks everyone.


Ended up going with 

(substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 4))

 

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