Dustin11 Posted May 20, 2013 Posted May 20, 2013 I'm looking for a way that I can trim some information off of a variable I have set. I'm setting the layer name of an entity to a variable by getting its layer name from the DXF list so it reads like this: "(8 . "G-GENL-TEXT")" and I'm looking to trim that down to just: "G-GENL-TEXT" so I can use it to set my current layer. Thanks. Quote
MSasu Posted May 20, 2013 Posted May 20, 2013 The answer is CDR function - the dotted pairs behave a little different than the lists. (cdr '(8 . "G-GENL-TEXT")) The reason is to allow you to extract the data from associated lists by preserving their form - atom or list: (cdr '(10 1.0 2.0 3.0)) Quote
BlackBox Posted May 20, 2013 Posted May 20, 2013 I'm looking for a way that I can trim some information off of a variable I have set. I'm setting the layer name of an entity to a variable by getting its layer name from the DXF list so it reads like this: "(8 . "G-GENL-TEXT")" and I'm looking to trim that down to just: "G-GENL-TEXT" so I can use it to set my current layer. Consider: (defun c:FOO (/ eName) (if (setq eName (car (entsel "\nSelect entity to set layer current: "))) (setvar 'clayer (cdr (assoc 8 (entget eName)))) ) (princ) ) ... Or simply use the LAYMCUR Command. Quote
Dustin11 Posted May 20, 2013 Author Posted May 20, 2013 ......I can't believe I didn't think of using the cdr function for that. Blackbox - I use the Laycur command later on in the code but I wanted to switch over to using setvar instead so the code is more automatide unstead of prompting the user to make a bunch of different selections. Thanks for the advice though. Quote
BlackBox Posted May 20, 2013 Posted May 20, 2013 ......I can't believe I didn't think of using the cdr function for that. Blackbox - I use the Laycur command later on in the code but I wanted to switch over to using setvar instead so the code is more automatide unstead of prompting the user to make a bunch of different selections. Thanks for the advice though. No worries; everyone needs a little reminder now and then. I only use Commands when advantageous... I usually prefer the Setvar method myself as well. Cheers Quote
Lee Mac Posted May 20, 2013 Posted May 20, 2013 In addition to the excellent information already provided, this post may also be of interest. 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.