Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Strip file extension

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Jonathan3891
541 Views, 4 Replies

Strip file extension

Is it possible to strip the file extension (.dwg) of a selected file using the method I have detailed below?

 

Here I am selecting a block and storing the block name in appdata.

 

(defun c:ttt (/)
  (setq PileType (getfiled "Select Pile Drawing" "Z:\\ECI CAD\\AutoCAD\\PileDriver\\Pile Data\\" "dwg" 8))
  (setcfg "AppData/PileDriver/Pile_Type" PileType)
  (princ)
  )

 

 

Here I am recalling the name of the block stored in appdata. 

 

(defun c:foo (/)
  (setq PileType (getcfg "AppData/PileDriver/Pile_Type"))
  (setq bname (??))
  )

 

Is it possible to strip the file extension (.dwg) from PileType and set it as bname?

 


Jonathan Norton
Blog | Linkedin
4 REPLIES 4
Message 2 of 5
pbejse
in reply to: Jonathan3891

look into vl-filename-base function

Message 3 of 5
Jonathan3891
in reply to: Jonathan3891

Thats exactly what I was looking for. Thank you!


Jonathan Norton
Blog | Linkedin
Message 4 of 5
ronjonp
in reply to: Jonathan3891

If you need a vanilla variant using substr works like so:

(substr (setq s "Drawing1.dwg") 1 (- (strlen s) 4))
Message 5 of 5
pbejse
in reply to: ronjonp

and another

(Cadr (fnsplitl PileType))

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost