Jump to content

AutoCAD Diesel substr function with embedded IF statement


barakar42

Recommended Posts

Hi,

 

I've been trying to use Diesel to get the drawing number from the folder structure, but the issue i'm having is that the job number isn't always 5 digits long, some up to 9 digits

 

I've got the code:

 

%<\AcDiesel $(substr,$(getvar,workingfolder),21, 5)>%

 

That gives me the correct job number if there's only 5 digits, e.g. C1234

 

Is it possible to add an if statement where the "5" is to count up until it hits the space after the job number?

If so how would i go about this as I've tried but I've not done any sort of coding for a long time

 

 

Link to comment
Share on other sites

What exactly are you trying to modify with the additional numbers in the expression?

 

You didn't post the actual Diesel expression, they are like $(+, $(getvar, thickness), 10).

 

What is the drawing number comprised of? If you just want that number, no need to modify by trimming the drawing number at all.

Link to comment
Share on other sites

15 hours ago, BIGAL said:

If you have Autocad as your profile says why not use lisp,  (getvar "dwgprefix") 

I've never really used lisp before apart from using other lisp commands other people have written

Link to comment
Share on other sites

5 hours ago, SLW210 said:

What exactly are you trying to modify with the additional numbers in the expression?

 

You didn't post the actual Diesel expression, they are like $(+, $(getvar, thickness), 10).

 

What is the drawing number comprised of? If you just want that number, no need to modify by trimming the drawing number at all.

So I'm trying to get the job number from the folder structure

 

I use getvar,workingfolder to get the full location of the drawing

 

And then I've added the subtr to cut off the first 21 digits of it

 

The job numbers can be "c1234".  But it could also be "abc12345"

 

That's why I was thinking of having an if statement as the 2nd part of the subtr expression 

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