Sweety Posted September 9, 2010 Posted September 9, 2010 Hello GUYs. OK. I have done some codes with Visual Lisp and VBA functions today, But I think the (vla-put-color ... & vla-put-LineWeight... are return error because I used them with "ByLayer" . So what's wrong with my routine PLEASE ? (if (and (setq ss (ssget)) (setq MyDocs (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) ) (vlax-for Ent MyDocs (vla-put-Layer Ent "0") (vla-put-LineType Ent "ByLayer") (vla-put-LineWeight Ent "ByLayer") (vla-put-color Ent "ByLayer") ) ) Thankxxxxxxxxxxxxxxxx Sweety. Quote
alanjt Posted September 9, 2010 Posted September 9, 2010 "ByLayer" is not a layer number, try 256. Quote
Se7en Posted September 9, 2010 Posted September 9, 2010 quickly: ; ver1 (vlax-put-property (vlax-Ename->Vla-Object (car (entsel))) 'Color acByLayer) ; ver 2 (vlax-put-property (vlax-Ename->Vla-Object (car (entsel))) 'Color 256) Quote
Sweety Posted September 9, 2010 Author Posted September 9, 2010 Nothing has changed with color "256" And what about (vla-put-LineWeight Ent "ByLayer") I thing It's also return error. Quote
Se7en Posted September 9, 2010 Posted September 9, 2010 *bleh* Did you even look in the help files? Because if you did, you would have seen this: "acLnWtByLayer". Quote
Sweety Posted September 9, 2010 Author Posted September 9, 2010 Is it difficult to that point ? Quote
Se7en Posted September 9, 2010 Posted September 9, 2010 Is it difficult to that point ? It's not difficult at all; I already gave you the answer once. Here is the answer again: (vlax-put-property (vlax-Ename->Vla-Object (car (entsel))) 'Color acByLayer) (vlax-put-property (vlax-Ename->Vla-Object (car (entsel))) 'LineWeight acLnWtByLayer) (vlax-put-property (vlax-Ename->Vla-Object (car (entsel))) 'LineType "ByLayer") Quote
BlackBox Posted September 10, 2010 Posted September 10, 2010 Hello again, Sweety. Both Alanjt and Se7en have given you sound advice for achieving your desired result(s). If you are not going to use a filtered selection set: (setq ss (ssget '((-4 . "<not") (8 . "0") (-4 . "not>")))) ... perhaps you'll find this to be more easy to follow: (defun c:TEST (/ ss) (vl-load-com) (cond (*activeDoc*) ((setq *activeDoc* (vla-get-activedocument (vlax-get-acad-object))))) (if (setq ss (ssget)) (progn (vlax-for Ent (setq ss (vla-get-ActiveSelectionSet *activeDoc*)) (if (/= "ByLayer" (vla-get-color Ent)) (vla-put-color Ent acByLayer)) (if (/= "0" (vla-get-layer Ent)) (vla-put-Layer Ent "0")) [color="#2e8b57"];| Missing Linetype check |;[/color] (if (and (vlax-property-available-p Ent 'linetype T) (/= "ByLayer" (vla-get-linetype Ent))) (vla-put-Linetype Ent "ByLayer")) (if (and (vlax-property-available-p Ent 'lineweight T) (/= "Bylayer" (vla-get-lineweight Ent))) (vla-put-Lineweight Ent acLnWtBylayer))) (vla-delete ss))) (princ)) ;_end defun I'll double check the code I've posted when I get to work in the morning, as I do not have AutoCAD available at the moment (I didn't opt to purchase AutoCAD for Mac when we finished Beta testing). Also note, that this can be done using Auto LISP, using foreach and ssname, or even lambda (as Alanjt has demonstrated in the past). Hope this helps! Quote
alanjt Posted September 10, 2010 Posted September 10, 2010 (vlax-ename->vla-object nil)? He delivered it that way just as a demonstration. There's no reason to completely break down a full selection with error checking, just to show how to apply an option to an object. Many give examples just like this all the time. It's just a little nicer than: (vlax-put-property <VLA-OBJECT> 'Color acByLayer) Hello again, Sweety. Both Alanjt and Se7en have given you sound advice for achieving your desired result(s). If you are not going to use a filtered selection set: (setq ss (ssget '((-4 . "<not") (8 . "0") (-4 . "not>")))) FYI... (ssget '((8 . "~0"))) Quote
BlackBox Posted September 10, 2010 Posted September 10, 2010 My comment was made for the OP's benefit (the question asker), and not for Se7en (the answer giver). I am confident that Se7en knows to avoid this (in professional use), and there's nothing wrong with posting in this format. *IF* the OP, or even someone else needing help, were to read that and not knowing any better adopt that as their standard method, then the poor sap might not know where they went wrong down the road. Certainly a full function with error checking is not necessary. I'm not suggesting that there should be. Had I posed the question, Se7en provided everything I would need to develop the correct answer. Perhaps a *slight* modification would be preferable: (if (setq eName (car (entsel))) (vlax-put-property (setq vlaObj (vlax-Ename->Vla-Object eName)) 'Color acByLayer) (vlax-put-property vlaObj 'LineWeight acLnWtByLayer) (vlax-put-property vlaObj 'LineType "ByLayer")) This method does require declared variables, but it too is also very quick to write, yet avoids the noted issue. Again, this is only an alternative... and my two cents. Edit: Ah, yes... the power of the tilda (~)! Thanks for the reminder. Quote
Sweety Posted September 10, 2010 Author Posted September 10, 2010 Hello again, Sweety. Both Alanjt and Se7en have given you sound advice for achieving your desired result(s). Thank you soooooooo much Renderman. I haven't tried your codes for now, But I just wanted to agree with you that Alanjt replies in all threads are very very poor, and not stright to the point in his following up replies. I meant, he doesn't bring any unless he see someone had brought an answer to the questioner, So he would interfer for defeating and being in the front. Unfortunetly. I would go back to you as soon as I try your nice works dear Renderman. Appreciated a lot HONEY. Sweety. Quote
alanjt Posted September 10, 2010 Posted September 10, 2010 My comment was made for the OP's benefit (the question asker), and not for Se7en (the answer giver).If it wasn't directed at Se7en (I feel so strange typing that when I know his real name), then I take it back. However, I will add that your 'question' was a bit ambiguous (possibly difficult for OP or other to comprehend), and being that it was posed as a question, I assumed it was directed at Se7en. I haven't tried your codes for now, But I just wanted to agree with you that Alanjt replies in all threads are very very poor, and not stright to the point in his following up replies. I meant, he doesn't bring any unless he see someone had brought an answer to the questioner, So he would interfer for defeating and being in the front. Unfortunetly. I take serious offense to this. I contribute to a lot of my time and information to this forum. I'll admit, my initial response to you was a little ambiguous, but I will not go along with your statement that I post poor responses and I only post to interfere. I do not appreciate your comments, and do not worry, I will stray far away from your questions (of which, many could easily be avoided if you spent five minutes in the help file, examining the proper use of a function). Quote
Sweety Posted September 10, 2010 Author Posted September 10, 2010 (of which, many could easily be avoided if you spent five minutes in the help file, examining the proper use of a function). I am not learnig everything form forums direclty, only when things being unleacer or ambiguous to me. And you'd better be open to opinoins in general and accept the opposite side's opinion. you have been laughting at me with your drops of replies. I do not appreciate your comments, and do not worry. Even though, I still respect all people's opinions no matter how bad they are. Sweety. Quote
alanjt Posted September 10, 2010 Posted September 10, 2010 I am not learnig everything form forums direclty, only when things being unleacer or ambiguous to me. And you'd better be open to opinoins in general and accept the opposite side's opinion. you have been laughting at me with your drops of replies. Even though, I still respect all people's opinions no matter how bad they are. Sweety. I'm not laughing at you, I'm annoyed at your out-of-line comments towards me. Quote
BlackBox Posted September 10, 2010 Posted September 10, 2010 While I appreciate your kind words toward me, your comments toward Alanjt are ill spoken, and incorrect. I have known Alanjt for a while now, and he's personally taught me a lot. I credit him (like it or not) with much of my programming capabilities, as I have only been programming for +/-6 months (The first few months of code were horrible, so I ignore those, ha ha!). Participation in these forums is voluntary, and done so at the discretion of the member. If someone has come in after the fact, as I have in this thread, that doesn't make their response any less, or more valid. You should evaluate their input at face value, and consider what it is they (the answer giver) are trying to teach you (the question asker). I have just learned something... More than once, I have done you a disservice, by offering a complete answer. Instead, I should be intentionally vague here and there, in order to allow you to find the missing piece(s). After all, that is what both Alanjt and Se7en have done for you prior to my joining this thread. You do not learn by being given the answers, you learn from figuring it out for yourself (with a little push in the right direction). Maybe you should read this: How To Ask Questions The Smart Way Someone smarter than I, offered me this resource recently, and I wish I had found it much earlier. I learned from it, and I hope you will too. Quote
Se7en Posted September 10, 2010 Posted September 10, 2010 alanjt, Dont worry about it. Its not like Sweety even bothered to take 5 minutes to construct a proper question. There wasnt any time given for thought, research, or consideration. The question might as well have been: "I want you to spend your time writing something for me to do THIS so do that please...thanx". Sweety, you treat me like garbage (disregard my time and input) and I will return the favor (Ignore your posts). RenderMan, Assumptions are made and applied liberally when posting. Whether it be when dealing with a troll or implying a higher process to a knowledgeable person. Quote
alanjt Posted September 10, 2010 Posted September 10, 2010 alanjt, Dont worry about it. Its not like Sweety even bothered to take 5 minutes to construct a proper question.Already forgotten. Sweety, you treat me like garbage (disregard my time and input) and I will return the favor (Ignore your posts). ditto Oh yeah, and thanks for the defense, RenderMan. Quote
BlackBox Posted September 10, 2010 Posted September 10, 2010 If it wasn't directed at Se7en (I feel so strange typing that when I know his real name), then I take it back. However, I will add that your 'question' was a bit ambiguous (possibly difficult for OP or other to comprehend), and being that it was posed as a question, I assumed it was directed at Se7en.... ... RenderMan, Assumptions are made and applied liberally when posting. Whether it be when dealing with a troll or implying a higher process to a knowledgeable person. Guys (Alanjt & Se7en) - Maybe I'm taking this stuff too seriously. I have clearly overstepped a line because of what took place (a spat?) in a separate thread. It may make no difference to either of you at this time (this is my assumption), as I cannot undo what has already been done, but I have deleted the post. I apologize for my recently flared temper, and contributing to the unnecessary banter, now in two separate threads. This has taught me a lot... I shall 'steer clear' for a bit, but I hope that we meet again (as friends?) one day. Despite my stubbornness, and ego, I appreciate the lesson, gentlemen. Sweety, you [have treated Alanjt and Se7en] like garbage ([disregarding their] time and input) and I will return the favor (Ignore your posts). Thrice. Sweety - Your baseless insults in this thread were mean, and unwarranted. You owe both Alanjt and Se7en an apology. Quote
alanjt Posted September 10, 2010 Posted September 10, 2010 Guys (Alanjt & Se7en) - Maybe I'm taking this stuff too seriously. I have clearly overstepped a line because of what took place (a spat?) in a separate thread. It may make no difference to either of you at this time (this is my assumption), as I cannot undo what has already been done, but I have deleted the post. I apologize for my recently flared temper, and contributing to the unnecessary banter, now in two separate threads. This has taught me a lot... I shall 'steer clear' for a bit, but I hope that we meet again (as friends?) one day. Despite my stubbornness, and ego, I appreciate the lesson, gentlemen. You've no reason to apologize to me. To put it plainly: we cool, don't leave. 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.