Jump to content

Appending text


StevJ

Recommended Posts

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

Link to comment
Share on other sites

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"))

Link to comment
Share on other sites

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

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