btraemoore Posted April 26, 2012 Share Posted April 26, 2012 ;;;get a working list of all the layers (vl-load-com) (setq acadDocument (vla-get-activedocument (vlax-get-acad-object))) (setq layertable (vla-get-layers acadDocument)) ;;;make layers an array and editable ;;;make the properites of the layers accessable ;;;check the names against a standard list of valid layer names ;;;remove valid layers from the working list ;;;check the first layers color ;;;get a list of all valid layers with that color from the standard layers list ;;;check the line type of the first layer ;;;get a list of all valid layers with same line type from the modified list ;;;change the layer name to the standard valid layer name this is my check list, I've gotten past step 1 and am at a loss now and I'm pretty sure im way off ... i need some redirection, can anybody help? Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 26, 2012 Share Posted April 26, 2012 This will help you build a list of layers associated lists: (setq theLayer (cdr (assoc 2 (tblnext "LAYER" 1)))) (while theLayer (setq listLayers (append listLayers (list (entget (tblobjname "LAYER" theLayer)))) theLayer (cdr (assoc 2 (tblnext "LAYER")))) ) Quote Link to comment Share on other sites More sharing options...
btraemoore Posted April 26, 2012 Author Share Posted April 26, 2012 awesome, this is a good start. now i need to figure out how to get the color. i was thinking vlax-dump or vla-getcolor but i tried them and was getting a listp error Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 26, 2012 Share Posted April 26, 2012 In layer's associated list the color is stored under DXF code 62. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 27, 2012 Share Posted April 27, 2012 Can you elaborate a bit more what it is that your actually trying to achieve is it some form of layer management for users or what ? Just ignoring code questions for a moment. Quote Link to comment Share on other sites More sharing options...
btraemoore Posted April 30, 2012 Author Share Posted April 30, 2012 I'm actually trying to make a routine that will automatically change the names of layers dependent upon the layer color and line type. Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 30, 2012 Share Posted April 30, 2012 Then, you should look for DXF codes 62 (color) and 6 (linetype). (setq assocLayer (tblsearch "LAYER" LayerName) theName (strcat (itoa (cdr (assoc 62 assocLayer))) ;color "-" (cdr (assoc 6 assocLayer)))) ;linetype Quote Link to comment Share on other sites More sharing options...
btraemoore Posted April 30, 2012 Author Share Posted April 30, 2012 yes, i defiantly used the code to set my lt and color variables, im trying to figure out how to get a table length so i can set my while loop, and then i have to figure out how to compare it to the list that i have. Quote Link to comment Share on other sites More sharing options...
pBe Posted April 30, 2012 Share Posted April 30, 2012 Will that be Linetype AND Color match? At any rate, I suppose you will be adding a suffix or prefix on the layer name and NOT replace the entire name. Quote Link to comment Share on other sites More sharing options...
btraemoore Posted April 30, 2012 Author Share Posted April 30, 2012 yes the Linetype and the color will match. No, I will be replacing the entire name. Once I have the list narrowed down to the LT and color that match the existing layer, im thinking of having it compare the first character in both name variables and choose the correct layer name to save based off that or having it evaluate the total matching characters in the applicable layer names via strcat ascii, maybe... Quote Link to comment Share on other sites More sharing options...
pBe Posted April 30, 2012 Share Posted April 30, 2012 yes the Linetype and the color will match. No, I will be replacing the entire name. I don't get it. Say for instance on the layer collection you have two or three that have the same LINETYPE and COLOR , what will happen then? Quote Link to comment Share on other sites More sharing options...
btraemoore Posted April 30, 2012 Author Share Posted April 30, 2012 yes the Linetype and the color will match. No, I will be replacing the entire name. Once I have the list narrowed down to the LT and color that match the existing layer, im thinking of having it compare the first character in both name variables and choose the correct layer name to save based off that or having it evaluate the total matching characters in the applicable layer names via strcat ascii, maybe... (vl-load-com) (setq acadDocument (vla-get-activedocument (vlax-get-acad-object))) (setq layertable (vla-get-layers acadDocument)) (repeat (setq Lay (tblnext "LAYER" 1)) (while (setq layLT (cdr (assoc 6 lay)) layCOLOR (cdr (assoc 62 lay)) layNM (cdr (assoc 2 lay)) );setq (open C:\\Documents and Settings\\moorerb\\Desktop\\scripting-lisp\\standardlayers.txt "r") this is the coding that i have so far. I haven't figured a way to end the loop yet, and still reading on how to evaluate each line in the delimited file, TSV as delimiter Quote Link to comment Share on other sites More sharing options...
btraemoore Posted April 30, 2012 Author Share Posted April 30, 2012 say i have 20 layers with the same LT and color, it will evaluate the name of the matching layer properties and if the first character of the layer in question matches the first character of one of the possible matches then it will save that name as the variable to change it to and if there are multiple matches then it will go down the line and compare the second character of the possible matches... so on and so forth, to get the most accurate name for the layer. Quote Link to comment Share on other sites More sharing options...
pBe Posted April 30, 2012 Share Posted April 30, 2012 (while (setq a (tblnext "LAYER" (null a))) (setq coll (list (cdr (assoc 6 a)) (cdr (assoc 62 a)) (cdr (assoc 2 a)))) (print coll);<<<<--- Do your thing here ) Can yu post here a part of that "standardlayers.txt" file Quote Link to comment Share on other sites More sharing options...
btraemoore Posted April 30, 2012 Author Share Posted April 30, 2012 0 7 CONTINUOUS2 3 CONTINUOUS BLDG 2 CONTINUOUS BLDG 7 CONTINUOUS BORDER 5 CONTINUOUS BORDER 7 CONTINUOUS CENTER 2 CENTER CENTER 7 CENTER CLINE 7 CENTER CLINES 7 CENTER2 COL 1 CONTINUOUS CONC 1 CONTINUOUS CONDUIT-HIDDEN 1 HIDDEN CONDUIT-HIDDEN 7 HIDDEN CONDUIT 1 CONTINUOUS CONDUIT 7 CONTINUOUS CONN 6 CONTINUOUS CONST 5 CONTINUOUS CONST 7 CONTINUOUS CONTROL 6 CONTINUOUS CONTROL 7 CONTINUOUS CPLPOVR 7 CONTINUOUS CPRT 4 CONTINUOUS CPRT 7 CONTINUOUS CUTLINE 5 HIDDEN CUTLINE 7 HIDDEN DASHED 2 DASHED DASHED 2 PHANTOM DASHED 7 PHANTOM DEFPOINTS 7 CONTINUOUS DEPT 3 CONTINUOUS DEPT 7 CONTINUOUS DIM 2 CONTINUOUS DIM 7 CONTINUOUS DIMN 1 CONTINUOUS DIMN 7 CONTINUOUS ELEC 1 HIDDEN ELEC 7 HIDDEN this is part of standardlayers.txt. the spaces are actually tab delimitation's Quote Link to comment Share on other sites More sharing options...
pBe Posted April 30, 2012 Share Posted April 30, 2012 Okay. Demonstrate for us thiese two lines here: ELEC 1 HIDDEN ELEC 7 HIDDEN If it finds a match. what then? what will be the new name? Anyhoo.. if the only problem is the loop. see previous post Quote Link to comment Share on other sites More sharing options...
btraemoore Posted April 30, 2012 Author Share Posted April 30, 2012 (edited) OLD layer name: ELECTRICAL layer color: 1 layer LT: HIDDEN (comparison to standardlayers.txt) NEW layer name: ELEC (command "-rename" "la" OLD NEW) its only comparing the color and linetype and if needed the characters in the name. More than likely it will need to compare the characters in the name Edited April 30, 2012 by btraemoore Quote Link to comment Share on other sites More sharing options...
pBe Posted April 30, 2012 Share Posted April 30, 2012 See if i get this right. ELECTRICAL/1/HIDDEN will be ELEC, and ELECTRICAL/7/HIDDEN will also be ELEC, is that right? Use wcmatch for name comparison or a predicate function that reduces the list for comparison using the frist character on the Layer name Quote Link to comment Share on other sites More sharing options...
btraemoore Posted April 30, 2012 Author Share Posted April 30, 2012 keep in mind that i am very new to lisp and do not know a lot of functions. my thought is that i will step though each existing layer checking the name against the list and if the name is not in my list, then run the function for changing the name. IE: all the crap with the color and lt checks. when i consider of the functionality of wcmatch with this routine, and correct me if im wrong, it would have to be its own function filtering the existing layer list prior to running my main routine?? Quote Link to comment Share on other sites More sharing options...
pBe Posted April 30, 2012 Share Posted April 30, 2012 all the crap with the color and lt checks. when i consider of the functionality of wcmatch with this routine, and correct me if im wrong, it would have to be its own function filtering the existing layer list prior to running my main routine?? Yup, sort of... i can write a snippet for you.... you didnt answer my question though, ELECTRICAL/1/HIDDEN will be ELEC, and ELECTRICAL/7/HIDDEN will also be ELEC, is that right? Quote Link to comment Share on other sites More sharing options...
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.