Jump to content

<-- this guy needs some help


btraemoore

Recommended Posts

;;;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?

Link to comment
Share on other sites

  • Replies 39
  • Created
  • Last Reply

Top Posters In This Topic

  • btraemoore

    22

  • pBe

    14

  • MSasu

    3

  • BIGAL

    1

Top Posters In This Topic

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"))))
)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

I'm actually trying to make a routine that will automatically change the names of layers dependent upon the layer color and line type.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 
(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

Link to comment
Share on other sites

0 7 CONTINUOUS

2 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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by btraemoore
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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