block swapping list question

Hello, i am wondering if any of you lisp experes can helpe me with one of ours.

Our drawings contain various parts that can be several different heights and colours, inserted by way of lisp routines.

We then have another lisp that we use when we want to change a bunch of them from one height/colour to another.

One such part is an upright, part name EU240, 100, 90 etc.

Some time ago we changed the part in main use to one called OUL240, 100, 90 etc.

So i attempted to amend the lisp to include this part group. I have amended it before to work with other new parts and no issue. But with this one it just does not swap the parts, though it does change the positional heights of them.(ie drops them down)

the additional lines added to the attched code are-

(if (wcmatch n "OU#*")

      (setq rn (strcat (substr n 1 2)   "0"))

and in the next section

(wcmatch rn "O#*")

I have tried all variations of the wildcard characters, but it just refuses to change the parts even though they are in the same folder location as the EU parts.

Am i missing something?

Comments

  • To be honest. I couldn't follow it. I would suggest however rewriting using "cond" instead of multiple "if"'s. This will make finding the error much easier. Also I know it's your private lisp, but commenting it would be beneficial to others looking at it.

  • Hi,

    If you are trying to wcmatch the two options use EU* and OUL*

    because using an # is for a single numeric character.

    while using an * is for any character sequence.

    currently you are using (wcmatch n "OU#*") which won't pick up OUL240, 100, 90 etc. because of the L.

    As mentioned above though - it is a little difficult to follow…

  • Sorry for the dely in saying thanks for the info, been a bit hectic and this has ended up on the back burner.

    i agree the code isnt as obvous as it could be, i didnt write it just inherited it.

    The lack of an 'L' was down to me trying to see if it would work with a shorter name; as i also creaed a part named Just Ou; but that made no difference.

    Very usefull info and i will see where it takes me.

    Thanks again.