ScoRm Posted August 15, 2018 Posted August 15, 2018 I have found an Autolisp that could help me do it, but I need something else, and IDK what to do. I do not know Any Autolisp coding at all so don't be harsh.. Here it is: (defun C:pl2layer (/ ss clayer i pline elevation layername) (setq ss (ssget '((0 . "LWPOLYLINE")))) (setq clayer (getvar "CLAYER")) (if ss (progn (setq i -1) (repeat (sslength ss) (setq i (1+ i) pline (ssname ss i) elevation (cdr (assoc 38 (entget pline))) layername (rtos elevation) ) (command ".layer" "make" layername "") (command ".change" pline "" "Properties" "LAyer" layername "") ) ) ) (setvar "CLAYER" clayer) ) but here is the problem, it makes a layer with ".0000" at the end. i only need the whole number.. Also what i really need is this: say your elevation is 899, i need it to be in layer 900 say your elevation is 899.5, i need it to be in layer 900 say your elevation is 899.9, i need it to be in layer 900 say your elevation is 900, i need it to be in layer 900 say your elevation is 900.5, i need it to be in layer 900 say your elevation is 900.9, i need it to be in layer 900 say your elevation is 901, i need it to be in layer 902 say your elevation is 901.5, i need it to be in layer 902 say your elevation is 901.9, i need it to be in layer 902 say your elevation is 902, i need it to be in layer 902 say your elevation is 902.5, i need it to be in layer 902 say your elevation is 902.9, i need it to be in layer 902 say your elevation is 903, i need it to be in layer 904 say your elevation is 903.5, i need it to be in layer 904 say your elevation is 903.9, i need it to be in layer 904 say your elevation is 904, i need it to be in layer 904 say your elevation is 904.5, i need it to be in layer 904 say your elevation is 904.9, i need it to be in layer 904 basically i my layer names are every 2, and that is where im lost. I dont know how to remove those decimal points, I also dont know how to implement what i really need them to be at... me so stupid, me so sorry Quote
BIGAL Posted August 16, 2018 Posted August 16, 2018 1st is simple layername (rtos elevation 2 2 ) this is decimal and 0.xx two decimal places Your changing the rules regarding roundup and round down normally this is round up for 0.5 round down for 0.49999 you will need to build a cond that looks at the value of the elevations and works out what it should be. 899.000 900.99999999 =900 901.0 902.99999 = 902 903.0 903.9999 = 904 etc Quote
ScoRm Posted August 16, 2018 Author Posted August 16, 2018 1st is simple layername (rtos elevation 2 2 ) this is decimal and 0.xx two decimal places Your changing the rules regarding roundup and round down normally this is round up for 0.5 round down for 0.49999 you will need to build a cond that looks at the value of the elevations and works out what it should be. 899.000 900.99999999 =900 901.0 902.99999 = 902 903.0 903.9999 = 904 etc BIGAL i got it!!! thanks for the insight I know its long, but f*ck it! it works! and that's all i need (defun c:ElevationLayer(/ ss clayer i pline elevation layername) (setq ss (ssget '((0 . "LWPOLYLINE")))) (setq clayer (getvar "CLAYER")) (if ss (progn (setq i -1) (repeat (sslength ss) (setq i (1+ i) pline (ssname ss i) elevation (cdr (assoc 38 (entget pline))) ) (cond ((<= elevation 669.9)(setq layername "NO_ELEV")) ((<= elevation 670.9)(setq layername "CONTOUR_EL670")) ((<= elevation 672.9)(setq layername "CONTOUR_EL672")) ((<= elevation 674.9)(setq layername "CONTOUR_EL674")) ((<= elevation 676.9)(setq layername "CONTOUR_EL676")) ((<= elevation 678.9)(setq layername "CONTOUR_EL678")) ((<= elevation 680.9)(setq layername "CONTOUR_EL680")) ((<= elevation 682.9)(setq layername "CONTOUR_EL682")) ((<= elevation 684.9)(setq layername "CONTOUR_EL684")) ((<= elevation 686.9)(setq layername "CONTOUR_EL686")) ((<= elevation 688.9)(setq layername "CONTOUR_EL688")) ((<= elevation 690.9)(setq layername "CONTOUR_EL690")) ((<= elevation 692.9)(setq layername "CONTOUR_EL692")) ((<= elevation 694.9)(setq layername "CONTOUR_EL694")) ((<= elevation 696.9)(setq layername "CONTOUR_EL696")) ((<= elevation 698.9)(setq layername "CONTOUR_EL698")) ((<= elevation 700.9)(setq layername "CONTOUR_EL700")) ((<= elevation 702.9)(setq layername "CONTOUR_EL702")) ((<= elevation 704.9)(setq layername "CONTOUR_EL704")) ((<= elevation 706.9)(setq layername "CONTOUR_EL706")) ((<= elevation 708.9)(setq layername "CONTOUR_EL708")) ((<= elevation 710.9)(setq layername "CONTOUR_EL710")) ((<= elevation 712.9)(setq layername "CONTOUR_EL712")) ((<= elevation 714.9)(setq layername "CONTOUR_EL714")) ((<= elevation 716.9)(setq layername "CONTOUR_EL716")) ((<= elevation 718.9)(setq layername "CONTOUR_EL718")) ((<= elevation 720.9)(setq layername "CONTOUR_EL720")) ((<= elevation 722.9)(setq layername "CONTOUR_EL722")) ((<= elevation 724.9)(setq layername "CONTOUR_EL724")) ((<= elevation 726.9)(setq layername "CONTOUR_EL726")) ((<= elevation 728.9)(setq layername "CONTOUR_EL728")) ((<= elevation 730.9)(setq layername "CONTOUR_EL730")) ((<= elevation 732.9)(setq layername "CONTOUR_EL732")) ((<= elevation 734.9)(setq layername "CONTOUR_EL734")) ((<= elevation 736.9)(setq layername "CONTOUR_EL736")) ((<= elevation 738.9)(setq layername "CONTOUR_EL738")) ((<= elevation 740.9)(setq layername "CONTOUR_EL740")) ((<= elevation 742.9)(setq layername "CONTOUR_EL742")) ((<= elevation 744.9)(setq layername "CONTOUR_EL744")) ((<= elevation 746.9)(setq layername "CONTOUR_EL746")) ((<= elevation 748.9)(setq layername "CONTOUR_EL748")) ((<= elevation 750.9)(setq layername "CONTOUR_EL750")) ((<= elevation 752.9)(setq layername "CONTOUR_EL752")) ((<= elevation 754.9)(setq layername "CONTOUR_EL754")) ((<= elevation 756.9)(setq layername "CONTOUR_EL756")) ((<= elevation 758.9)(setq layername "CONTOUR_EL758")) ((<= elevation 760.9)(setq layername "CONTOUR_EL760")) ((<= elevation 762.9)(setq layername "CONTOUR_EL762")) ((<= elevation 764.9)(setq layername "CONTOUR_EL764")) ((<= elevation 766.9)(setq layername "CONTOUR_EL766")) ((<= elevation 768.9)(setq layername "CONTOUR_EL768")) ((<= elevation 770.9)(setq layername "CONTOUR_EL770")) ((<= elevation 772.9)(setq layername "CONTOUR_EL772")) ((<= elevation 774.9)(setq layername "CONTOUR_EL774")) ((<= elevation 776.9)(setq layername "CONTOUR_EL776")) ((<= elevation 778.9)(setq layername "CONTOUR_EL778")) ((<= elevation 780.9)(setq layername "CONTOUR_EL780")) ((<= elevation 782.9)(setq layername "CONTOUR_EL782")) ((<= elevation 784.9)(setq layername "CONTOUR_EL784")) ((<= elevation 786.9)(setq layername "CONTOUR_EL786")) ((<= elevation 788.9)(setq layername "CONTOUR_EL788")) ((<= elevation 790.9)(setq layername "CONTOUR_EL790")) ((<= elevation 792.9)(setq layername "CONTOUR_EL792")) ((<= elevation 794.9)(setq layername "CONTOUR_EL794")) ((<= elevation 796.9)(setq layername "CONTOUR_EL796")) ((<= elevation 798.9)(setq layername "CONTOUR_EL798")) ((<= elevation 800.9)(setq layername "CONTOUR_EL800")) ((<= elevation 802.9)(setq layername "CONTOUR_EL802")) ((<= elevation 804.9)(setq layername "CONTOUR_EL804")) ((<= elevation 806.9)(setq layername "CONTOUR_EL806")) ((<= elevation 808.9)(setq layername "CONTOUR_EL808")) ((<= elevation 810.9)(setq layername "CONTOUR_EL810")) ((<= elevation 812.9)(setq layername "CONTOUR_EL812")) ((<= elevation 814.9)(setq layername "CONTOUR_EL814")) ((<= elevation 816.9)(setq layername "CONTOUR_EL816")) ((<= elevation 818.9)(setq layername "CONTOUR_EL818")) ((<= elevation 820.9)(setq layername "CONTOUR_EL820")) ((<= elevation 822.9)(setq layername "CONTOUR_EL822")) ((<= elevation 824.9)(setq layername "CONTOUR_EL824")) ((<= elevation 826.9)(setq layername "CONTOUR_EL826")) ((<= elevation 828.9)(setq layername "CONTOUR_EL828")) ((<= elevation 830.9)(setq layername "CONTOUR_EL830")) ((<= elevation 832.9)(setq layername "CONTOUR_EL832")) ((<= elevation 834.9)(setq layername "CONTOUR_EL834")) ((<= elevation 836.9)(setq layername "CONTOUR_EL836")) ((<= elevation 838.9)(setq layername "CONTOUR_EL838")) ((<= elevation 840.9)(setq layername "CONTOUR_EL840")) ((<= elevation 842.9)(setq layername "CONTOUR_EL842")) ((<= elevation 844.9)(setq layername "CONTOUR_EL844")) ((<= elevation 846.9)(setq layername "CONTOUR_EL846")) ((<= elevation 848.9)(setq layername "CONTOUR_EL848")) ((<= elevation 850.9)(setq layername "CONTOUR_EL850")) ((<= elevation 852.9)(setq layername "CONTOUR_EL852")) ((<= elevation 854.9)(setq layername "CONTOUR_EL854")) ((<= elevation 856.9)(setq layername "CONTOUR_EL856")) ((<= elevation 858.9)(setq layername "CONTOUR_EL858")) ((<= elevation 860.9)(setq layername "CONTOUR_EL860")) ((<= elevation 862.9)(setq layername "CONTOUR_EL862")) ((<= elevation 864.9)(setq layername "CONTOUR_EL864")) ((<= elevation 866.9)(setq layername "CONTOUR_EL866")) ((<= elevation 868.9)(setq layername "CONTOUR_EL868")) ((<= elevation 870.9)(setq layername "CONTOUR_EL870")) ((<= elevation 872.9)(setq layername "CONTOUR_EL872")) ((<= elevation 874.9)(setq layername "CONTOUR_EL874")) ((<= elevation 876.9)(setq layername "CONTOUR_EL876")) ((<= elevation 878.9)(setq layername "CONTOUR_EL878")) ((<= elevation 880.9)(setq layername "CONTOUR_EL880")) ((<= elevation 882.9)(setq layername "CONTOUR_EL882")) ((<= elevation 884.9)(setq layername "CONTOUR_EL884")) ((<= elevation 886.9)(setq layername "CONTOUR_EL886")) ((<= elevation 888.9)(setq layername "CONTOUR_EL888")) ((<= elevation 890.9)(setq layername "CONTOUR_EL890")) ((<= elevation 892.9)(setq layername "CONTOUR_EL892")) ((<= elevation 894.9)(setq layername "CONTOUR_EL894")) ((<= elevation 896.9)(setq layername "CONTOUR_EL896")) ((<= elevation 898.9)(setq layername "CONTOUR_EL898")) ((<= elevation 900.9)(setq layername "CONTOUR_EL900")) ((<= elevation 902.9)(setq layername "CONTOUR_EL902")) ((<= elevation 904.9)(setq layername "CONTOUR_EL904")) ((<= elevation 906.9)(setq layername "CONTOUR_EL906")) ((<= elevation 908.9)(setq layername "CONTOUR_EL908")) ((<= elevation 910.9)(setq layername "CONTOUR_EL910")) ((<= elevation 912.9)(setq layername "CONTOUR_EL912")) ((<= elevation 914.9)(setq layername "CONTOUR_EL914")) ((<= elevation 916.9)(setq layername "CONTOUR_EL916")) ((<= elevation 918.9)(setq layername "CONTOUR_EL918")) ((<= elevation 920.9)(setq layername "CONTOUR_EL920")) ((<= elevation 922.9)(setq layername "CONTOUR_EL922")) ((<= elevation 924.9)(setq layername "CONTOUR_EL924")) ((<= elevation 926.9)(setq layername "CONTOUR_EL926")) ((<= elevation 928.9)(setq layername "CONTOUR_EL928")) ((<= elevation 930.9)(setq layername "CONTOUR_EL930")) ((<= elevation 932.9)(setq layername "CONTOUR_EL932")) ((<= elevation 934.9)(setq layername "CONTOUR_EL934")) ((<= elevation 936.9)(setq layername "CONTOUR_EL936")) ((<= elevation 938.9)(setq layername "CONTOUR_EL938")) ((<= elevation 940.9)(setq layername "CONTOUR_EL940")) ((<= elevation 942.9)(setq layername "CONTOUR_EL942")) ((<= elevation 944.9)(setq layername "CONTOUR_EL944")) ((<= elevation 946.9)(setq layername "CONTOUR_EL946")) ((<= elevation 948.9)(setq layername "CONTOUR_EL948")) ((<= elevation 950.9)(setq layername "CONTOUR_EL950")) ((<= elevation 952.9)(setq layername "CONTOUR_EL952")) ((<= elevation 954.9)(setq layername "CONTOUR_EL954")) ((<= elevation 956.9)(setq layername "CONTOUR_EL956")) ((<= elevation 958.9)(setq layername "CONTOUR_EL958")) ((<= elevation 960.9)(setq layername "CONTOUR_EL960")) ((<= elevation 962.9)(setq layername "CONTOUR_EL962")) ((<= elevation 964.9)(setq layername "CONTOUR_EL964")) ((<= elevation 966.9)(setq layername "CONTOUR_EL966")) ((<= elevation 968.9)(setq layername "CONTOUR_EL968")) ((<= elevation 970.9)(setq layername "CONTOUR_EL970")) ((<= elevation 972.9)(setq layername "CONTOUR_EL972")) ((<= elevation 974.9)(setq layername "CONTOUR_EL974")) ((<= elevation 976.9)(setq layername "CONTOUR_EL976")) ((<= elevation 978.9)(setq layername "CONTOUR_EL978")) ((<= elevation 980.9)(setq layername "CONTOUR_EL980")) ((<= elevation 982.9)(setq layername "CONTOUR_EL982")) ((<= elevation 984.9)(setq layername "CONTOUR_EL984")) ((<= elevation 986.9)(setq layername "CONTOUR_EL986")) ((<= elevation 988.9)(setq layername "CONTOUR_EL988")) ((<= elevation 990.9)(setq layername "CONTOUR_EL990")) ((<= elevation 992.9)(setq layername "CONTOUR_EL992")) ((<= elevation 994.9)(setq layername "CONTOUR_EL994")) ((<= elevation 996.9)(setq layername "CONTOUR_EL996")) ((<= elevation 998.9)(setq layername "CONTOUR_EL998")) ((<= elevation 1000.9)(setq layername "CONTOUR_EL1000")) ((<= elevation 1002.9)(setq layername "CONTOUR_EL1002")) ((<= elevation 1004.9)(setq layername "CONTOUR_EL1004")) ((<= elevation 1006.9)(setq layername "CONTOUR_EL1006")) ((<= elevation 1008.9)(setq layername "CONTOUR_EL1008")) ((<= elevation 1010.9)(setq layername "CONTOUR_EL1010")) ((<= elevation 1012.9)(setq layername "CONTOUR_EL1012")) ((<= elevation 1014.9)(setq layername "CONTOUR_EL1014")) ((<= elevation 1016.9)(setq layername "CONTOUR_EL1016")) ((<= elevation 1018.9)(setq layername "CONTOUR_EL1018")) ((<= elevation 1020.9)(setq layername "CONTOUR_EL1020")) ((<= elevation 1022.9)(setq layername "CONTOUR_EL1022")) ((<= elevation 1024.9)(setq layername "CONTOUR_EL1024")) ((<= elevation 1026.9)(setq layername "CONTOUR_EL1026")) ((<= elevation 1028.9)(setq layername "CONTOUR_EL1028")) ((<= elevation 1030.9)(setq layername "CONTOUR_EL1030")) ((<= elevation 1032.9)(setq layername "CONTOUR_EL1032")) ((<= elevation 1034.9)(setq layername "CONTOUR_EL1034")) ((<= elevation 1036.9)(setq layername "CONTOUR_EL1036")) ((<= elevation 1038.9)(setq layername "CONTOUR_EL1038")) ((<= elevation 1040.9)(setq layername "CONTOUR_EL1040")) ((<= elevation 1042.9)(setq layername "CONTOUR_EL1042")) ((<= elevation 1044.9)(setq layername "CONTOUR_EL1044")) ((<= elevation 1046.9)(setq layername "CONTOUR_EL1046")) ((<= elevation 1048.9)(setq layername "CONTOUR_EL1048")) ((<= elevation 1050.9)(setq layername "CONTOUR_EL1050")) ((<= elevation 1052.9)(setq layername "CONTOUR_EL1052")) ((<= elevation 1054.9)(setq layername "CONTOUR_EL1054")) ((<= elevation 1056.9)(setq layername "CONTOUR_EL1056")) ((<= elevation 1058.9)(setq layername "CONTOUR_EL1058")) ((<= elevation 1060.9)(setq layername "CONTOUR_EL1060")) ((<= elevation 1062.9)(setq layername "CONTOUR_EL1062")) ((<= elevation 1064.9)(setq layername "CONTOUR_EL1064")) ((<= elevation 1066.9)(setq layername "CONTOUR_EL1066")) ((<= elevation 1068.9)(setq layername "CONTOUR_EL1068")) ((<= elevation 1070.9)(setq layername "CONTOUR_EL1070")) ((<= elevation 1072.9)(setq layername "CONTOUR_EL1072")) ((<= elevation 1074.9)(setq layername "CONTOUR_EL1074")) ((<= elevation 1076.9)(setq layername "CONTOUR_EL1076")) ((<= elevation 1078.9)(setq layername "CONTOUR_EL1078")) ((<= elevation 1080.9)(setq layername "CONTOUR_EL1080")) ((<= elevation 1082.9)(setq layername "CONTOUR_EL1082")) ((<= elevation 1084.9)(setq layername "CONTOUR_EL1084")) ((<= elevation 1086.9)(setq layername "CONTOUR_EL1086")) ((<= elevation 1088.9)(setq layername "CONTOUR_EL1088")) ((<= elevation 1090.9)(setq layername "CONTOUR_EL1090")) ((<= elevation 1092.9)(setq layername "CONTOUR_EL1092")) ((<= elevation 1094.9)(setq layername "CONTOUR_EL1094")) ((<= elevation 1096.9)(setq layername "CONTOUR_EL1096")) ((<= elevation 1098.9)(setq layername "CONTOUR_EL1098")) ((<= elevation 1100.9)(setq layername "CONTOUR_EL1100")) ((<= elevation 1102.9)(setq layername "CONTOUR_EL1102")) ((<= elevation 1104.9)(setq layername "CONTOUR_EL1104")) ((<= elevation 1106.9)(setq layername "CONTOUR_EL1106")) ((<= elevation 1108.9)(setq layername "CONTOUR_EL1108")) ((<= elevation 1110.9)(setq layername "CONTOUR_EL1110")) ((<= elevation 1112.9)(setq layername "CONTOUR_EL1112")) ((<= elevation 1114.9)(setq layername "CONTOUR_EL1114")) ((<= elevation 1116.9)(setq layername "CONTOUR_EL1116")) ((<= elevation 1118.9)(setq layername "CONTOUR_EL1118")) ((<= elevation 1120.9)(setq layername "CONTOUR_EL1120")) ((<= elevation 1122.9)(setq layername "CONTOUR_EL1122")) ((<= elevation 1124.9)(setq layername "CONTOUR_EL1124")) ((<= elevation 1126.9)(setq layername "CONTOUR_EL1126")) ((<= elevation 1128.9)(setq layername "CONTOUR_EL1128")) ((<= elevation 1130.9)(setq layername "CONTOUR_EL1130")) ((<= elevation 1132.9)(setq layername "CONTOUR_EL1132")) ((<= elevation 1134.9)(setq layername "CONTOUR_EL1134")) ((<= elevation 1136.9)(setq layername "CONTOUR_EL1136")) ((<= elevation 1138.9)(setq layername "CONTOUR_EL1138")) ((<= elevation 1140.9)(setq layername "CONTOUR_EL1140")) ((<= elevation 1142.9)(setq layername "CONTOUR_EL1142")) ((<= elevation 1144.9)(setq layername "CONTOUR_EL1144")) ((<= elevation 1146.9)(setq layername "CONTOUR_EL1146")) ((<= elevation 1148.9)(setq layername "CONTOUR_EL1148")) ((<= elevation 1150.9)(setq layername "CONTOUR_EL1150")) ((<= elevation 1152.9)(setq layername "CONTOUR_EL1152")) ((<= elevation 1154.9)(setq layername "CONTOUR_EL1154")) ((<= elevation 1156.9)(setq layername "CONTOUR_EL1156")) ((<= elevation 1158.9)(setq layername "CONTOUR_EL1158")) ((<= elevation 1160.9)(setq layername "CONTOUR_EL1160")) ((<= elevation 1162.9)(setq layername "CONTOUR_EL1162")) ((<= elevation 1164.9)(setq layername "CONTOUR_EL1164")) ((<= elevation 1166.9)(setq layername "CONTOUR_EL1166")) ((<= elevation 1168.9)(setq layername "CONTOUR_EL1168")) ((<= elevation 1170.9)(setq layername "CONTOUR_EL1170")) ((<= elevation 1172.9)(setq layername "CONTOUR_EL1172")) ((<= elevation 1174.9)(setq layername "CONTOUR_EL1174")) ((<= elevation 1176.9)(setq layername "CONTOUR_EL1176")) ((<= elevation 1178.9)(setq layername "CONTOUR_EL1178")) ((<= elevation 1180.9)(setq layername "CONTOUR_EL1180")) ((<= elevation 1182.9)(setq layername "CONTOUR_EL1182")) ((<= elevation 1184.9)(setq layername "CONTOUR_EL1184")) ((<= elevation 1186.9)(setq layername "CONTOUR_EL1186")) ((<= elevation 1188.9)(setq layername "CONTOUR_EL1188")) ((<= elevation 1190.9)(setq layername "CONTOUR_EL1190")) ((<= elevation 1192.9)(setq layername "CONTOUR_EL1192")) ((<= elevation 1194.9)(setq layername "CONTOUR_EL1194")) ((<= elevation 1196.9)(setq layername "CONTOUR_EL1196")) ((<= elevation 1198.9)(setq layername "CONTOUR_EL1198")) ((<= elevation 1200.9)(setq layername "CONTOUR_EL1200")) ) (command ".layer" "make" layername "") (command ".change" pline "" "Properties" "LAyer" layername "") ); repeat the routine to all plines in ss ) ) (setvar "CLAYER" clayer) ) Quote
Tharwat Posted August 16, 2018 Posted August 16, 2018 A simpler way (rtos (fix elevation) 2 0)) Much simpler. (itoa (fix elevation)) Quote
marko_ribar Posted August 16, 2018 Posted August 16, 2018 Instead of beeing typo masohistic you could simplify your code to just : (defun c:ElevationLayer ( / ss clayer i pline elevation layername ) (setq ss (ssget '((0 . "LWPOLYLINE")))) (setq clayer (getvar "CLAYER")) (if ss (progn (setq i -1) (repeat (sslength ss) (setq i (1+ i) pline (ssname ss i) elevation (cdr (assoc 38 (entget pline))) ) (cond ( (<= elevation 669.99999999) (setq layername "NO_ELEV") ) ( (= (rem (fix elevation) 2) 1) (setq layername (strcat "CONTOUR_EL" (itoa (1- (fix elevation))))) ) ( t (setq layername (strcat "CONTOUR_EL" (itoa (fix elevation)))) ) ) (command "_.layer" "_make" layername "") (command "_.change" pline "" "_Properties" "_LAyer" layername "") ) ) ) (setvar "CLAYER" clayer) (princ) ) Quote
ScoRm Posted August 16, 2018 Author Posted August 16, 2018 Instead of beeing typo masohistic you could simplify your code to just : (defun c:ElevationLayer ( / ss clayer i pline elevation layername ) (setq ss (ssget '((0 . "LWPOLYLINE")))) (setq clayer (getvar "CLAYER")) (if ss (progn (setq i -1) (repeat (sslength ss) (setq i (1+ i) pline (ssname ss i) elevation (cdr (assoc 38 (entget pline))) ) (cond ( (<= elevation 669.99999999) (setq layername "NO_ELEV") ) ( (= (rem (fix elevation) 2) 1) (setq layername (strcat "CONTOUR_EL" (itoa (1- (fix elevation))))) ) ( t (setq layername (strcat "CONTOUR_EL" (itoa (fix elevation)))) ) ) (command "_.layer" "_make" layername "") (command "_.change" pline "" "_Properties" "_LAyer" layername "") ) ) ) (setvar "CLAYER" clayer) (princ) ) polylines go to wrong layer though... ex: elevation 903 goes to layer 902, its supposed to be at 904 its like this: 901 - 902.9 = 902 903 - 904.9 = 904 905 - 906.9 = 906 907 - 908.9 = 908 Quote
marko_ribar Posted August 17, 2018 Posted August 17, 2018 Change this : (cond ( (<= elevation 669.99999999) (setq layername "NO_ELEV") ) ( (= (rem (fix elevation) 2) 1) (setq layername (strcat "CONTOUR_EL" (itoa ([b][color=red]1-[/color][/b] (fix elevation))))) ) ( t (setq layername (strcat "CONTOUR_EL" (itoa (fix elevation)))) ) ) To this : (cond ( (<= elevation 669.99999999) (setq layername "NO_ELEV") ) ( (= (rem (fix elevation) 2) 1) (setq layername (strcat "CONTOUR_EL" (itoa ([b][color=red]1+[/color][/b] (fix elevation))))) ) ( t (setq layername (strcat "CONTOUR_EL" (itoa (fix elevation)))) ) ) Regards, M.R. Quote
ronjonp Posted August 17, 2018 Posted August 17, 2018 I don't understand why you'd put an elevation of 901 on layer 902 (/= 901 902) Quote
hanhphuc Posted August 17, 2018 Posted August 17, 2018 (edited) (defun foo (x) (* (fix (/ (+ x 1.0) 2.0)) 2.0 ) ) ? elevation 903 goes to layer 902, its supposed to be at 904 its like this: 901 - 902.9 = 902 903 - 904.9 = 904 905 - 906.9 = 906 907 - 908.9 = 908 (foreach x '(901 902. 902.9 903 904.1 904.9 905 905.5 906.9 907 908.9 909.1) (princ (strcat "\n" (rtos x 2 [color="red"]1[/color]) " = " (rtos (foo x)2 [color="red"]0[/color]) )) ) (princ) Edited August 17, 2018 by hanhphuc red Quote
ScoRm Posted August 17, 2018 Author Posted August 17, 2018 Change this : (cond ( (<= elevation 669.99999999) (setq layername "NO_ELEV") ) ( (= (rem (fix elevation) 2) 1) (setq layername (strcat "CONTOUR_EL" (itoa ([b][color=red]1-[/color][/b] (fix elevation))))) ) ( t (setq layername (strcat "CONTOUR_EL" (itoa (fix elevation)))) ) ) To this : (cond ( (<= elevation 669.99999999) (setq layername "NO_ELEV") ) ( (= (rem (fix elevation) 2) 1) (setq layername (strcat "CONTOUR_EL" (itoa ([b][color=red]1+[/color][/b] (fix elevation))))) ) ( t (setq layername (strcat "CONTOUR_EL" (itoa (fix elevation)))) ) ) Regards, M.R. wow! i really need to learn this lisp for autocad thingy, look at that! the long code into fewer lines! thanks so much! I don't understand why you'd put an elevation of 901 on layer 902 (/= 901 902) IKR?! so wierd! well, dont blame me lol, thats what the boss wants, im just a pawn. Quote
LIBRAT Posted February 24, 2022 Posted February 24, 2022 How about 0.00001 - 2 to contour elev 2 i hope you can help me i'am new in Autocad. Quote
marko_ribar Posted February 25, 2022 Posted February 25, 2022 But original OP requested 901-902.9 => 902 ... i.e. (1-3 => 2; 3-5 => 4...) If I understood you, you want (0-2 => 2; 2-4 => 4...) and not (0-2 => 1; 2-4 => 3...) For (0-2 => 2; 2-4 => 4...) : (cond ( (= (rem (fix elevation) 2) 1) (setq layername (strcat "CONTOUR_EL" (itoa (1+ (fix elevation))))) ) ( t (setq layername (strcat "CONTOUR_EL" (itoa (+ (fix elevation) 2)))) ) ) For (0-2 => 1; 2-4 => 3...) : (cond ( (= (rem (fix elevation) 2) 1) (setq layername (strcat "CONTOUR_EL" (itoa (fix elevation)))) ) ( t (setq layername (strcat "CONTOUR_EL" (itoa (1+ (fix elevation))))) ) ) 1 Quote
LIBRAT Posted February 25, 2022 Posted February 25, 2022 (edited) 50 minutes ago, marko_ribar said: But original OP requested 901-902.9 => 902 ... i.e. (1-3 => 2; 3-5 => 4...) If I understood you, you want (0-2 => 2; 2-4 => 4...) and not (0-2 => 1; 2-4 => 3...) For (0-2 => 2; 2-4 => 4...) : (cond ( (= (rem (fix elevation) 2) 1) (setq layername (strcat "CONTOUR_EL" (itoa (1+ (fix elevation))))) ) ( t (setq layername (strcat "CONTOUR_EL" (itoa (+ (fix elevation) 2)))) ) ) For (0-2 => 1; 2-4 => 3...) : (cond ( (= (rem (fix elevation) 2) 1) (setq layername (strcat "CONTOUR_EL" (itoa (fix elevation)))) ) ( t (setq layername (strcat "CONTOUR_EL" (itoa (1+ (fix elevation))))) ) ) Thank you sir i'll try to change the code tomorrow at the office. I don't have computer at home. I'am just learning autocad when breaktime at work. Excuse me sir if this code work on this example: 0.0001-2.0000 => CONTOUR_EL 2 2.0001-4.0000 => CONTOUR_EL 4 4.0001-6.0000 => CONTOUR_EL 6 And so on Edited February 25, 2022 by LIBRAT Quote
LIBRAT Posted February 25, 2022 Posted February 25, 2022 1 hour ago, marko_ribar said: But original OP requested 901-902.9 => 902 ... i.e. (1-3 => 2; 3-5 => 4...) If I understood you, you want (0-2 => 2; 2-4 => 4...) and not (0-2 => 1; 2-4 => 3...) For (0-2 => 2; 2-4 => 4...) : (cond ( (= (rem (fix elevation) 2) 1) (setq layername (strcat "CONTOUR_EL" (itoa (1+ (fix elevation))))) ) ( t (setq layername (strcat "CONTOUR_EL" (itoa (+ (fix elevation) 2)))) ) ) For (0-2 => 1; 2-4 => 3...) : (cond ( (= (rem (fix elevation) 2) 1) (setq layername (strcat "CONTOUR_EL" (itoa (fix elevation)))) ) ( t (setq layername (strcat "CONTOUR_EL" (itoa (1+ (fix elevation))))) ) ) Thank you sir i'll to the code tomorrow at the office in my breaktime. I don't have computer at home, i'am just learning autocad at work during 1hr break. Thank you sir Can i ask if this code work in this example: 0.0001 - 2.0000 => CONTOUR_EL 2 2.0001 - 4.0000 => CONTOUR_EL 4 4.0001 - 6.0000 => CONTOUR_EL 6 And so on OR 900.0001 - 902.0000 => CONTOUR_EL 902 902.0001 - 904.0000 => CONTOUR_EL 904 904.0001 - 906.0000 => CONTOUR_EL 906 And so on Thank you again sir godbless you always. Quote
tombu Posted February 25, 2022 Posted February 25, 2022 15 hours ago, LIBRAT said: How about 0.00001 - 2 to contour elev 2 i hope you can help me i'am new in Autocad. ;;; Written by Doug Broad ;;; If value given 'to' argument is a real, a real is returned. ;;; Rounds up to nearest multiple of 'to' real or integer. (defun roundup (value to / try) (setq to (abs to) try (+(* to (fix (/ ((if (minusp value) - +) value (* to 0.5)) to)))to) ) (if(eq (+ 0.1 try) (+ 0.1 value to))(- try to) try) ) ; examples: ; Command: (roundup 0.00001 2) ; 2 ; Command: (roundup 30.01 5) ; 35 ; Command: (roundup 30 5) ; 30 (roundup 0.00001 2) returns 2 1 Quote
LIBRAT Posted November 29, 2022 Posted November 29, 2022 How about all kind of objects that has z value not only poly line? Elevationlayer Quote
Steven P Posted November 29, 2022 Posted November 29, 2022 2 hours ago, LIBRAT said: How about all kind of objects that has z value not only poly line? Elevationlayer If you look at the code you are using it will have something like: (setq ss (ssget '((0 . "LWPOLYLINE")))) Where ssget gets a 'selection set' of objects. This is limited by the next part '((0 . "LWPOLYLINE")) to polylines - delete that and it will select all objects. Should then have: (setq ss (ssget)) Note that you can also change LWPOLYLINE to other object types, and use wild cards, replace it with "CIRCLE" to just select circles, of "*LINE" (the * is a wildcard) to select all lines and polylines - it is worth reading more about selection sets. 1 Quote
LIBRAT Posted November 30, 2022 Posted November 30, 2022 How about in this code do i have to delete pline code? elevation (cdr (assoc 38 (entget pline))) (command ".change" pline "" "Properties" "LAyer" layername "") Quote
Steven P Posted November 30, 2022 Posted November 30, 2022 No, shouldn't need to Here after the (command ...." anything in " " are text as you would type it in the command line, without the " " this is a variable defined earlier in the LISP. So PLINE is a variable - could be called anything. If you look further up in the LISP you should find what pline is set to be (it will have something like (setq pline ....) - and an internet search will show you what it is if you want to find out what the LISP is doing. In this case, there is no need to change anything else 1 Quote
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.