Kerry Brown Posted August 4, 2010 Posted August 4, 2010 You are amazing. Always hurry gets blind eyes. And how crazy is that my variable would give T to continue since that it would return NIL ???? So I should look for another way to get it work well ... And I may back to you .... Agree ? Regards, Tharwat The answer is simple once you know the problem !! correct your test : (= sty "Closed") or write it this way :- (initget 1 "Closed Opened ") (if (setq sty (getkword "\nSpecify the MLINE Style [Closed Opened ]: ")) (setvar "cmlstyle" sty) ) Quote
Tharwat Posted August 4, 2010 Author Posted August 4, 2010 Wonderful..... If the MLSytle is a available, things are running perfectly. Otherwise it would be rejected without considering the ALERT msg .. (initget 1 "Closed Opened") (if (setq sty (getkword "\nSpecify the MLineSty [Closed Opened]:")) (setvar 'cmlstyle sty) (alert "The chosen MLStyle is not avaliable") ) Why the alert is not caaling for the mistake ? Quote
Kerry Brown Posted August 4, 2010 Posted August 4, 2010 The Alert only fires if the STY variable is nil. You aren't/haven't tested if the Style exists. Quote
Kerry Brown Posted August 4, 2010 Posted August 4, 2010 Any idea to set a specific MLine Style on when codes are running .Of course I have created the Mline Styles for Closed, Opened in the drawing. ;; Thanks Tharwat And you DID say it existed .... have the rules changed again ??? Quote
Tharwat Posted August 4, 2010 Author Posted August 4, 2010 YES I agree , But by chance I tried it in a new drawing, And I received variable setting rejected: CMLSTYLE "Closed" I thought the Alert would appear for the user to declare that not existed ..... That's all Best Regards, Quote
Kerry Brown Posted August 4, 2010 Posted August 4, 2010 Why would you think that ?? Programming is an exact science. Wishes and hopes do not count. Quote
Kerry Brown Posted August 4, 2010 Posted August 4, 2010 Do you know how to test is the MultiLineStyle exists ?? Quote
Kerry Brown Posted August 4, 2010 Posted August 4, 2010 and Do you know how to make a MultiLineStyle programmatically ?? Quote
Tharwat Posted August 4, 2010 Author Posted August 4, 2010 Here is what I am working at .. (defun c:du (/ curlay width style) (setq curlay (getvar "clayer")) (if (not (tblsearch "layer" "ACDUCT")) (command "._-layer" "_make" "ACDUCT" "_ltype" "continuous" "" "_color" "142" "" "") (setvar 'clayer "acduct") ) (setq width (getint "\nSpecify width of Duct: ")) (initget "Closed Opened First-open Last-open") (if ([color="red"]eq[/color] (setq sty (getkword "\nSpecify the MLineSty [Closed Opened First-open Last-open]:"))[color="red"]T[/color]) (setvar 'cmlstyle sty) (progn (alert "The chosen MLStyle is not avaliable") (exit))) (command "_mline" "_J" "_z" "_scale" width) (command pause) (setvar "clayer" curlay) (princ) ) With the modifications the Alert has just called me for the result NIL. Regards. Quote
Tharwat Posted August 4, 2010 Author Posted August 4, 2010 and Do you know how to make a MultiLineStyle programmatically ?? This is what I would like to know. If you do it that would be such a very big faviour to me. Thanks Quote
Kerry Brown Posted August 4, 2010 Posted August 4, 2010 Load this: (defun kdub:MLINESTYLE-GET (Name / mlsty-DICT MLSty) (if (setq mlsty-DICT (dictsearch (Namedobjdict) "ACAD_MLINESTYLE")) (while (and mlsty-DICT (not (setq MLSty (if (and (assoc 3 mlsty-DICT) (= (strcase (cdr (assoc 3 mlsty-DICT))) (strcase Name))) (list (strcase Name) (cdr (cadr (member (assoc 3 mlsty-DICT) mlsty-DICT)))) ) ) ) ) (setq mlsty-DICT (cdr (member (assoc 3 mlsty-DICT) mlsty-DICT))) ) ) MLSty ) run these in a drawing that has the styles set and post the results. (entget (cadr (kdub:MLINESTYLE-GET "Closed") )) (entget (cadr (kdub:MLINESTYLE-GET "Opened") )) Quote
Kerry Brown Posted August 4, 2010 Posted August 4, 2010 To get a list of the StyleNames in a drawing : load this library routine : (defun massoc (key alist / x nlist) (foreach x alist (if (eq key (car x)) (setq nlist (cons (cdr x) nlist)) ) ) (reverse nlist) ) then run this (setq MultiLineStyle_lst (massoc 3 (entget (cdr (cadr (member '(3 . "ACAD_MLINESTYLE") (entget (namedobjdict)) )))) ) ) Quote
Kerry Brown Posted August 4, 2010 Posted August 4, 2010 Here is what I am working at .. (defun c:du (/ curlay width style) < .. > (initget "Closed Opened First-open Last-open") (if ([color="red"]eq[/color] (setq sty (getkword "\nSpecify the MLineSty [Closed Opened First-open Last-open]:"))[color="red"]T[/color]) (setvar 'cmlstyle sty) < .. > Why are you using EQ to T test ??? We've just spen 25 posts demonstrating that the variable sty will be either a STRING or nil EQ is designed to Determines whether two expressions are identical. We just want to check that it has a value, yes ?? Quote
Tharwat Posted August 4, 2010 Author Posted August 4, 2010 Great work .... Kerry. You caught my weak point with MLine Styles. But the suffering problem that I am usually facing is that the DEFUN function which is running alone like the last one you posted. There are lots of things to study from your valued codes. Regards Quote
Kerry Brown Posted August 4, 2010 Posted August 4, 2010 Great work .... Kerry. You caught my weak point with MLine Styles. But the suffering problem that I am usually facing is that the DEFUN function which is running alone like the last one you posted. There are lots of things to study from your valued codes. Regards Sorry I don't understand your comment You don't need a defun to test. In the VLIDE simply select a lisp statement and press the 'Load Selection' button Like this: Quote
Kerry Brown Posted August 4, 2010 Posted August 4, 2010 can you post the results for post #31 for ALL the styleNames you want to make in new drawings. It's past my bedtime and I want to get this finished. [added] we'll also need (entget (cadr (kdub:MLINESTYLE-GET "First-open") )) (entget (cadr (kdub:MLINESTYLE-GET "Last-open") )) Quote
Tharwat Posted August 4, 2010 Author Posted August 4, 2010 YES, I did it that way , and I got the list of the MLStyle in my drawing . But most of your codes, I mean the looping of codes are new to me, so I am studying them and hopefully I would understand them the right way .... Quote
Tharwat Posted August 4, 2010 Author Posted August 4, 2010 Here they are . ("CLOSED" "OPENED" "Standard") Regards Quote
Kerry Brown Posted August 4, 2010 Posted August 4, 2010 With the code in post #31 We need the results of (entget (cadr (kdub:MLINESTYLE-GET "Closed") )) (entget (cadr (kdub:MLINESTYLE-GET "Opened") )) (entget (cadr (kdub:MLINESTYLE-GET "First-open") )) (entget (cadr (kdub:MLINESTYLE-GET "Last-open") )) so I know how you want the styles defined { using entmake }. Quote
Kerry Brown Posted August 4, 2010 Posted August 4, 2010 I'm going to bed. I'l leave you in the hands of the night-shift. 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.