Jump to content

lisp version of diesel


pmxcad

Recommended Posts

Hello,

iàm looking for the lisp version of this diesel expression:

%%

 

It gets the last character of the filename. XXXXX-A (revision A)

the filename lenght could be different so i want it to count from end to the beginning.

 

Thanks,

 

PmxCAD

Link to comment
Share on other sites

Hello,

iàm looking for the lisp version of this diesel expression:

%%

 

It gets the last character of the filename. XXXXX-A (revision A)

the filename lenght could be different so i want it to count from end to the beginning.

 

The LISP translation would be:

 

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

 

 

However, one advantage of using LISP is the ability to more effectively test for conditions, and utilize both variables/parameters, and sub-functions:

 

(vl-load-com)

(defun _GetRevision (dwgName / i)
 ;; Example: (_GetRevision "XXXXX-A.dwg")
 ;; Returns: "A"
 (if (setq i (vl-string-search "-" dwgName))
   (substr dwgName (+ 2 i) 1)
 )
)

 

 

 

Cheers

Link to comment
Share on other sites

(chr (last (vl-string->list (vl-filename-base (getvar 'dwgname)))))

((lambda (fn) (substr fn (strlen fn))) (vl-filename-base (getvar 'dwgname)))

Link to comment
Share on other sites

... Another that leaves the file extension, given OP's request for last character:

 

(defun _GetRevision (dwgName / i)
 ;; Example: (_GetRevision "XXXXX-A.dwg")
 ;; Returns: "A"
 (if (setq i (vl-string-search "." dwgName))
   (substr dwgName i 1)
 )
)

Link to comment
Share on other sites

Yes it works, but it works only for 1 tab.

I use it in a script for plotting to pdf. Takes the active layou tab name with the revision from the filename to create a pdf. (tabname-A.PDF)

 

it goes wrong with the next tab.

The script stops before it is completed.

It seems that data remains in memory.

 

what am I doing wrong?

 

PmxCAD

 

 

 

(setq Revision (substr (getvar 'dwgname) (- (strlen (getvar 'dwgname)) 5) 2))
(setq DwgN (getvar "CTAB"))
(setq Fname (substr DwgN 1 (- (strlen DwgN)0)))
(setq name (strcat (getvar "DWGPREFIX") Fname Revision".pdf"))
-plot




!name


Link to comment
Share on other sites

AUTOMATICPUB ?

What does this variable?

 

It enables/disabled the AUTOPUBLISH mechanism first implemented back in 2009 version... I use it daily for plans production to produce a PDF each time I SAVE a drawing, and have even customized the behavior with this.

 

HTH

Link to comment
Share on other sites

This will plot all your pdf's from layouts to the same location as the dwg and uses the layout name for each sheet

http://www.cadtutor.net/forum/showthread.php?84430-Move-layout-Rename-layouts-Goto-layout

 

version 2 is plot range

http://www.cadtutor.net/forum/showthread.php?84430-Move-layout-Rename-layouts-Goto-layout

Link to comment
Share on other sites

BlackBox, Bigal I'll try but I think it does not work in my case.

I like the layout plotting to PDF with layout name and behind the revision letter of the DWG file.

Not all layouts has to be plotted to PDF, some plotted to DWF.

Plotting with a script also sets the PDF to the DWG folder.

I just want to know why the script stops when I want to plot. Another layout

Maybe I should look over it again.

Anyone have an idea?

 

PmxCAD

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