Mirror pline and safe in new layer

Mirror pline and safe in new layer

Anonymous
Not applicable
1,167 Views
6 Replies
Message 1 of 7

Mirror pline and safe in new layer

Anonymous
Not applicable

Hello guys,

 

with the following code I try to mirror a pline at the x-axis and put it on a new defined layer, named like the first layer from which it got copied, but renamed through adding 180°. - except C000-Ebene and C180-Ebene !!

 

Example: Layer is called "C090-Ebene", so the renamed layer must be called "C270-Ebene" and so on.

 


(if (and ((/= layname "C000-EBENE") (/= layname "C180-EBENE")))
(progn (setq mirror_lay (strcat "-C" (AddLeadingZeros (rtos (+ zeileCE_wert 180.) 2 0) 3) "-EBENE") );SETQ
(command "_mirror" (ssget "L") "" "0,0" "1,0" "_n") (command "_layer" "_new" mirror_lay "") (command "_chprop" (ssget "L") "" "_layer" mirror_lay "") );PROGN );IF

Addleadingzeros is a function, which calculates the name and works properly.

 

I got this message: ; Fehler: no function definition: nil

0 Likes
Accepted solutions (2)
1,168 Views
6 Replies
Replies (6)
Message 2 of 7

john.uhden
Mentor
Mentor
Accepted solution
I don't see where zeileCE_wert is being set, but the "no function definition" failure indicates that a function was called that does not exist. That is usually the case of the programmer spelling the function wrong. There is no other function called in your code other than AddLeadingZeros. Maybe that function is calling another erroneous function.
Also, are you sure you want that hyphen before "C"? You also appear to have an extra pair of parentheses after (and. Actually that may be the "no function." Yes, I think that's it.

John F. Uhden

Message 3 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

I agree with @john.uhden.  This line:

 

(if (and ((/= layname "C000-EBENE") (/= layname "C180-EBENE")))

 

should probably be like this:

 

(if (and (/= layname "C000-EBENE") (/= layname "C180-EBENE"))

Kent Cooper, AIA
Message 4 of 7

ВeekeeCZ
Consultant
Consultant

If you have this...

 

(rtos (+ zeileCE_wert 180.) 2 0)

... which is ALWAYS bigger than 100, why do you need add any zeros?

 

 

BTW If this part is not include in code you did not post...

 

(setq zeileCE_wert (+ zeileCE_wert (if (< zeileCE_wert 180.)
                                     180.
                                     -180.)))

...should not be added? Then (addLeadingZeros) has a point.

  

Message 5 of 7

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:

.... If this part is not include in code you did not post...

 

(setq zeileCE_wert (+ zeileCE_wert (if (< zeileCE_wert 180.)
                                     180.
                                     -180.)))

...should not be added? Then (addLeadingZeros) has a point.


There's also a way to avoid the need to check whether the result is going to end up greater than 360 degrees, and get the less-than-360 result regardless of the initial value.  But it does require working in radians if it's to reduce the amount of code.  If you can convert related things to work in radians [which could simplify other things, too], then you can use (angtos) on the addition of pi radians to the initial value, and if the result comes out to more than 2pi, it converts it down automatically.  For example, if you're starting at 270 degrees [= (* pi 1.5) in radians], and you add 180 degrees [= pi], you get not 450, but 90 back, directly:

 

(angtos (+ (* pi 1.5) pi) 0 0)

"90"

 

You could, of course, do the same with your working values in degrees instead of radians, using a degrees-to-radians converter to adjust the starting value for that addition.  But unless you have other things to use that conversion for, or you have such a converter typically loaded already, it might take as much additional code as @ВeekeeCZ's approach above that checks the initial value and adds either positive or negative 180 to it.  But if you have a converter already loaded [often called (dtr)], or within this routine to use for other things too, you can just do:

...

   (setq mirror_lay
        (strcat "-C" (AddLeadingZeros (angtos (+ (dtr zeileCE_wert) pi) 0 0) 3) "-EBENE")
   );SETQ

...

and not need to bother about the possibility of it's coming out more than 360.

Kent Cooper, AIA
Message 6 of 7

Anonymous
Not applicable
Hello BeekeeCZ, actually it is a vallue between 000 and 180, that's why I need the zeros. In my previous code I considered this case, but thank's for the tip!
0 Likes
Message 7 of 7

Anonymous
Not applicable
Hello Kent, as I mentioned that the values are in between 0 and 180 this is not more neccessary - the angle is almost given as a string 🙂
0 Likes