StevJ Posted June 20, 2018 Share Posted June 20, 2018 Greetings, and a question. I’m trying to modify the naming of a model space view that is created with a custom program written long ago. Currently, the model space view name made by this program is the drawing file name, minus the “.dwg”. I have been partially successful, in that the last six characters are removed with this bit. (defun dwg() (setq dname (getvar "DWGNAME")) (setq strleg (strlen dname)) (setq strleg1(- strleg 6)) (setq drawname (substr dname 1 strleg1)) ) Just to fill in some info, The view is established in another part of the program with this. PT5 and PT6 are upper left and lower right corners of the view, chosen earlier in the program. (command "view" "w" drawname pt5 pt6) So I’m removing the last 6 characters of the file name with the third line, but I would like to append the characters H1 to the end of that resultant string. This is probably way easier than I’m trying to make it. What is the best way to accomplish this? I’ve concentrated all my attempts at line four, but all my attempts at including the text as text or as a variable are met with syntax errors, so I admit frustrated defeat. Is there a way H1 can be appended directly? The drawing file name has the following template: 2 numbers/2 letters/2 numbers/2 numbers or letters/./dwg My goal is for this view name to be the first 6 characters of the file name with H1 appended. Example: Dwg name = 25EG03B7.dwg Program will name the view: 25EG03B7 I can get it name the view : 25EG03 Trying to make the view name: 25EG03H1 I make a lot of these model space views, but only one per drawing, and just trying to automate so it can be done reliably. Thanks for any suggestions, Steve Quote Link to comment Share on other sites More sharing options...
rlx Posted June 20, 2018 Share Posted June 20, 2018 (strcat (substr "25EG03B7.dwg" 1 6) "H1") Quote Link to comment Share on other sites More sharing options...
dlanorh Posted June 20, 2018 Share Posted June 20, 2018 Greetings, and a question. I’m trying to modify the naming of a model space view that is created with a custom program written long ago. Currently, the model space view name made by this program is the drawing file name, minus the “.dwg”. I have been partially successful, in that the last six characters are removed with this bit. (defun dwg() (setq dname (getvar "DWGNAME")) (setq strleg (strlen dname)) (setq strleg1(- strleg 6)) (setq drawname (substr dname 1 strleg1)) ) Just to fill in some info, The view is established in another part of the program with this. PT5 and PT6 are upper left and lower right corners of the view, chosen earlier in the program. (command "view" "w" drawname pt5 pt6) So I’m removing the last 6 characters of the file name with the third line, but I would like to append the characters H1 to the end of that resultant string. This is probably way easier than I’m trying to make it. What is the best way to accomplish this? I’ve concentrated all my attempts at line four, but all my attempts at including the text as text or as a variable are met with syntax errors, so I admit frustrated defeat. Is there a way H1 can be appended directly? The drawing file name has the following template: 2 numbers/2 letters/2 numbers/2 numbers or letters/./dwg My goal is for this view name to be the first 6 characters of the file name with H1 appended. Example: Dwg name = 25EG03B7.dwg Program will name the view: 25EG03B7 I can get it name the view : 25EG03 Trying to make the view name: 25EG03H1 I make a lot of these model space views, but only one per drawing, and just trying to automate so it can be done reliably. Thanks for any suggestions, Steve Try (setq drawname (strcat (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 6)) "H1")) Quote Link to comment Share on other sites More sharing options...
StevJ Posted June 20, 2018 Author Share Posted June 20, 2018 Thank you both for your replies. I found rlx's version hard codes a drawing name into the process, and I was unable to successfully wedge the variable into it to take advantage of its brevity. dlanorh's version is exactly what I needed to make the program perform as required. Thank you, Steve Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.