+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default Something wrong with CLAYER

    Registered forum members do not see this ad.

    Hello
    Something wrong with making layer current and CLAYER,
    Code:
    (defun c:ww (/ curlay width)
      (prompt "This is Duct Design program . ...")
      (setq curlay (getvar "clayer"))
        (if (/= (cdr(setq ser(tblsearch "layer" "acduct")))"acduct")
           (progn
    	(command "_-layer" "_make" "ACDUCT" "_ltype" "continuous" "" "_color" "142" "" "")
            (command "_-layer" "_set" "ACDUCT" "" ""))
      (setvar "clayer" "ACDUCT"))
      (setq width (getint"\nSpecify width of Duct:"))
      (command "_mline" "_J" "_z" "_scale" width )
      (setvar "clayer" curlay)
      (princ)
      )
    Regards
    Tharwat

  2. #2
    Super Member profcad's Avatar
    Computer Details
    profcad's Computer Details
    Operating System:
    Windows Vista Ultimate
    Computer:
    Dell
    CPU:
    Dual - Six-Core Xeon
    RAM:
    12GB
    Graphics:
    NVida 4400
    Monitor:
    DUAL 22" WIDESCREEN
    Using
    Revit 2012
    Join Date
    Dec 2005
    Location
    Oklahoma City, OK
    Posts
    825

    Default

    I think this is what you are looking for...

    I removed the code
    (command "_-layer" "_set" "ACDUCT" "" ""))


    Code:
    (defun c:ww2 (/ curlay width)
      (prompt "This is Duct Design program . ...")
      (setq curlay (getvar "clayer"))
        (if (/= (cdr(setq ser(tblsearch "layer" "acduct")))"acduct")
           (progn
             (command "_-layer" "_make" "ACDUCT" "_ltype" "continuous" "" "_color" "142" "" "")
             (setvar "clayer" "ACDUCT")
           );progn
          );if
      (setq width (getint"\nSpecify width of Duct:"))
      (command "_mline" "_J" "_z" "_scale" width )
      (setvar "clayer" curlay)
      (princ)
      )
    John Helton
    Professor of CAD
    Oklahoma City Community College
    Oklahoma City, OK

  3. #3
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default

    Quote Originally Posted by profcad View Post
    I think this is what you are looking for...

    I removed the code
    (command "_-layer" "_set" "ACDUCT" "" ""))

    Code:
    (defun c:ww2 (/ curlay width)
      (prompt "This is Duct Design program . ...")
      (setq curlay (getvar "clayer"))
        (if (/= (cdr(setq ser(tblsearch "layer" "acduct")))"acduct")
           (progn
             (command "_-layer" "_make" "ACDUCT" "_ltype" "continuous" "" "_color" "142" "" "")
             (setvar "clayer" "ACDUCT")
           );progn
          );if
      (setvar "layer" "ACDUCT")
      (setq width (getint"\nSpecify width of Duct:"))
      (command "_mline" "_J" "_z" "_scale" width )
      (setvar "clayer" curlay)
      (princ)
      )
    Thanks for your reply , But the Clayer is still not responding by putting the current layer "ACDUCT" on, and to implement the following mline works through that layer.

    Any other solution would be highly apprecaited.
    Best Regards.

    Tharwat

  4. #4
    Super Member David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    1,926

    Default

    Using (setvar "CLAYER" ) isn't the best way to create a layer

    It takes a bit more error trapping etc:

    Code:
    (defun SetLayer (name / ldef flag)
      (command "_.LAYER")
      (if (not (tblsearch "LAYER" name))
          (command "_Make" name)
          (progn
            (setq ldef (tblsearch "LAYER" name)
                  flag (cdr (assoc 70 ldef)))
            (and (= (logand flag  1)  1)
                 (command "_Thaw" name))
            (and (minusp (cdr (assoc 62 ldef)))
                 (command "_On" name))
            (and (= (logand flag  4)  4)
                 (command "_Unlock" name))
            (and (= (logand flag 16) 16)
                 (princ "\nCannot Set To XRef Dependent Layer")
                 (quit))
            (command "_Set" name)))
      (command "")
      name)

    Code:
    (and (/= (strcase (getvar "CLAYER")) "ACDUCT")
         (SetLayer "ACDUCT")
         (command "_.LAYER" "_LT" "Continuous" "ACDUCT" ......  ""))
    Checking for (snvalid) is also a good thing.

    -David
    R12 (Dos) - A2K

  5. #5
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default

    Thanks David
    But SetLayer is not function definition in my system. And the way you making a layer is not familiar to me .


    I do not know ...... anyway thank you.

  6. #6
    Super Member profcad's Avatar
    Computer Details
    profcad's Computer Details
    Operating System:
    Windows Vista Ultimate
    Computer:
    Dell
    CPU:
    Dual - Six-Core Xeon
    RAM:
    12GB
    Graphics:
    NVida 4400
    Monitor:
    DUAL 22" WIDESCREEN
    Using
    Revit 2012
    Join Date
    Dec 2005
    Location
    Oklahoma City, OK
    Posts
    825

    Default

    tharwat313,

    The problem is with the mline command itself. You need a way to input multiple pauses for the ponits that you pick. The original program is running the last line (setvar "clayer" currlay) before the completes the mline command.

    I simplified the if statement, added a while loop to catch all the points for the mline command and a default duct width.

    Code:
    (defun c:ww3 (/ curlay width)
      (prompt "This is Duct Design program . ...")
      (setq curlay (getvar "clayer"))
        (if (tblsearch "layer" "acduct")  ;if layer exist, set it current, if not create it.
             (command "_-layer" "_set" "ACDUCT" "")
             (command "_-layer" "_make" "ACDUCT" "_ltype" "continuous" "" "_color" "142" "" "")
          );if
      (setq width (getint"\nSpecify width of Duct <10>: "))
      (if (null width) (setq width 10))
      (command "_mline" "_J" "_z" "_scale" width )
      (while 
          (= (logand (getvar "cmdactive") 1) 1)
          (command pause)
        );while
      (setvar "clayer" curlay)
      (princ)
      )
    John Helton
    Professor of CAD
    Oklahoma City Community College
    Oklahoma City, OK

  7. #7
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default

    Registered forum members do not see this ad.

    Mr. Profcad

    Really wonderful that's what I have been looking for.

    So you pause the command mline by the use of (command pause) and during that period, the Layer created or set current according to the situations and reinvoked the command of Mline .... Am I right ... ?


    Thank you soooo much
    Best Regards
    Tharwat

Similar Threads

  1. Can someone see where I'm going wrong?
    By Fire_col in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 26th Mar 2010, 02:36 pm
  2. what have i done wrong
    By AJSmith in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 4th Feb 2010, 08:34 pm
  3. What's wrong with this?
    By guitarguy1685 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 28th Jan 2010, 10:51 am
  4. what am i doing wrong?
    By crumpysmom in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 8th Apr 2008, 07:26 pm
  5. What's wrong?
    By Baçon in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 10th May 2005, 10:30 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts