Jump to content

Recommended Posts

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

  • Replies 49
  • Created
  • Last Reply

Top Posters In This Topic

  • Kerry Brown

    27

  • Tharwat

    22

  • Lee Mac

    1

Top Posters In This Topic

Posted Images

Posted

Wonderful..... :D

 

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 ?

Posted

The Alert only fires if the STY variable is nil.

 

You aren't/haven't tested if the Style exists.

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

Posted

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,

Posted

Why would you think that ??

 

Programming is an exact science.

 

Wishes and hopes do not count.

Posted

Do you know how to test is the MultiLineStyle exists ??

Posted

and Do you know how to make a MultiLineStyle programmatically ??

Posted

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

 

Regards.

Posted
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

Posted

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

Posted

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

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

Posted

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

Posted
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:

Load Selection.PNG

Posted

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

Posted

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

Posted

Here they are .

 

("CLOSED" "OPENED" "Standard")

 

Regards

Posted

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

Posted

I'm going to bed.

I'l leave you in the hands of the night-shift.

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