See the top rated post in this thread. Click here

Results 1 to 7 of 7

Thread: Need help with code

  1. #1
    100 Club
    Join Date
    2007-02
    Location
    Porto
    Posts
    107
    Login to Give a bone
    0

    Default Need help with code

    Hi,
    I am doing a small program and I'm having some problems. Does someone can help me resolve the code?

    Code:
    ;;;***********************************************************************************
    ;;;;;;MAKE ALL LAYERS ON
    
    (vl-load-com) 
    (setq acadDocument (vla-get-activedocument (vlax-get-acad-object))) 
    (setq theLayers (vla-get-layers acadDocument)) 
    (vlax-for item theLayers (vlax-put-property item "LayerOn" ':vlax-true) ) 
    
    ;;;***********************************************************************************
    ;;;;;;CREATE LAYER TMF IN COLOR 10
    
    	(setq ln (getvar "clayer"))
    	(setq ss (ssget))
    	(if (= (tblsearch "layer" "TMF") nil)
    	(command "layer" "make" "TMF" "color" "10" "" "lt" "bylayer" """"))
    	(command "chprop" ss "" "la" "TMF" "ltype" "bylayer" "color" "bylayer""")
    	(setvar "clayer" ln)
    	(setvar "cmdecho" ce)
    	(princ)
    )
    
    ;;;***********************************************************************************
    ;;;;;;MOVE ALL TO LAYER TMF COLOR 10
    
    (vl-load-com)
    (vlax-for blk (vla-get-blocks
            (vla-get-ActiveDocument
              (vlax-get-acad-object)
            )
              )
      (vlax-for obj blk
        (vla-put-Layer obj "TMF")
        (vla-put-Color obj 10)
      )
    )
    
    
    ;;;***********************************************************************************
    ;;;;;;ZOOM EXTENTS
    
    (setq qa_ss_all (ssget "X"));setq
      
      (if (/= qa_ss_all nil)
        (progn
          (command "_.ZOOM" "EXTENTS");command
          );progn
        );if
    
    ;;;***********************************************************************************
    ;;;;;;REMOVE ALL DIMENSIONS
    
      (if (/= (setq ssdim (ssget "X" (list (cons 0 "DIMENSION")))) nil) (setq dexist 1) (setq dexist nil) )
      (if (= dexist 1)
        (progn
          (command "erase" ssdim "")
          (princ "\nAll Dimensions Removed")
        )
        (princ "\nNo Dimensions Found")
      )
    
    
    ;;;***********************************************************************************
    ;;;;;;REMOVE ALL POINTS
    
      (if (/= (setq sspt (ssget "X" (list (cons 0 "POINT")))) nil) (setq pexist 1) (setq pexist nil) )
      (if (= pexist 1)
        (progn
          (command "erase" sspt "")
          (princ "\nAll Points Removed")
        )
        (princ "\nNo Points Found")
      )
      (princ)
    )
    
    ;;;***********************************************************************************
    ;;;;;;REMOVE HATCH
    
      (if (/= (setq sshtch (ssget "X" (list (cons 0 "HATCH")))) nil)
        (setq Hexist 1)
        (setq Hexist nil)
      )
      (if (= Hexist 1)
        (progn
          (command "erase" sshtch "")
          (princ "\nAll Hatching Removed")
        )
        (princ "\nNo Hatching Found")
      )
      (princ)
    )
    
    ;;;***********************************************************************************
    ;;;;;;REMOVE SOLID
    
      (if (/= (setq sssld (ssget "X" (list (cons 0 "SOLID")))) nil) (setq sexist 1) (setq sexist nil) )
      (if (= sexist 1)
        (progn
          (command "erase" sssld "")
          (princ "\nAll Solid Fill Removed")
        )
        (princ "\nNo Solid Fill Found")
      )
      (princ)
    )
    
    ;;;***********************************************************************************
    ;;;;;;CHANGE ALL TEXT (MTEXT AND TEXT) TO ROMANS
    
    (vl-load-com)
    (vlax-for
      ts
      (vla-get-textstyles (vla-get-activedocument (vlax-get-acad-object)))
      (if (not (eq (vla-get-Name ts) ""))
        (vla-put-fontfile ts "ROMANS")
      )
    )
    
    
    ;;;***********************************************************************************
    ;;;;;;DO A CLEANE (AUDIT AND PURGE) AND SAVE TO CURRENT VERSION
    
    (DEFUN NOECHO (/)
      (SETQ CE (GETVAR "CMDECHO"))
      (SETVAR "CMDECHO" 0)
      (COMMAND "_.Undo" "_Begin")
    ) ;_ end of defun
    ;;  ----
    (DEFUN ECHOON (/)
      (COMMAND "_.Undo" "_End")
      (SETVAR "CMDECHO" CE)
      (PRINC)
    ) ;_ end of defun
    ;;  ----
    (DEFUN AUDITFIX	()
      (COMMAND "_.Audit" "_Yes")
      (COMMAND "_.Regen")
    ) ;_ end of defun
    ;;  ----
    (DEFUN C:CLEANSAVE (/ CE)
      ;;  ----
      (DEFUN *ERROR* (MSG)
        (IF
          (OR
    	(/= MSG "Function cancelled")
    	(= MSG "quit / exit abort")
          ) ;_ end of OR
           (PRINC (STRCAT "\n\tERROR : " MSG "\n"))
           (PRINC)
        ) ;_ end of IF
        (COMMAND "_.Undo" "End")
        (COMMAND "_.U")
        (IF	CE
          (SETVAR "CMDECHO" CE)
        ) ;_ end of IF
        (PRINC)
      ) ;_ end of DEFUN
      ;;  ----
      (NOECHO)
      ;;  ----
      (AUDITFIX)
      (COMMAND "_.QSave") ;|Revised for AutoCAD 2007|;
      ;;  ----
      (PRINC "\n\tDrawing Auditted and Saved\n\tin AutoCAD current format. \n") ;|Revised for AutoCAD 2007|;
      (ECHOON)
    See attachment
    Thanks
    Attached Files Attached Files

  2. #2
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Need help with code

    Where is your problem occurring within the code? If you're not sure you can open it in VLIDE and under the Debug Tool bar menu select animate and then you can load and run the program and it will step through the program until it errors out then you will not at what part of the code to try and fix.

  3. #3
    100 Club
    Join Date
    2007-02
    Location
    Porto
    Posts
    107
    Login to Give a bone
    0

    Default Re: Need help with code

    Quote Originally Posted by Lions60 View Post
    Where is your problem occurring within the code? If you're not sure you can open it in VLIDE and under the Debug Tool bar menu select animate and then you can load and run the program and it will step through the program until it errors out then you will not at what part of the code to try and fix.
    Thank you. I try to put this peace of code to work, but it has errors when i run in autocad.

  4. #4
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    1

    Default Re: Need help with code

    You can start to remove the extra right parenthesis ) at line :
    20
    74
    91
    105

    and add a missing right parenthesis ) at the very last line :
    166

    then add after line 12 a missing variable ce
    (setq ce (getvar "cmdecho"))


    You may now be able to run the code, and start to debug, take care of variables and tune it up.

    : ) Happy Computing !

    kennet

  5. #5
    100 Club
    Join Date
    2007-02
    Location
    Porto
    Posts
    107
    Login to Give a bone
    0

    Default Re: Need help with code

    kennet
    Thank you. I had made that but it still display error:
    "Invalid linetype name.
    < Funcao Concluida >Function cancelled; error: An error has occurred inside the
    *error* functionAutoCAD variable setting rejected: "blipmode" nil
    Enter loaded linetype name or [?] <CONTINUOUS>:
    Invalid linetype name.
    Enter loaded linetype name or [?] <CONTINUOUS>:
    Enter name list of layer(s) for linetype "CONTINUOUS" <TMF>:
    Enter an option
    [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck
    /Unlock/stAte/Description/rEconcile]:"

    Look file attach
    Attached Files Attached Files

  6. #6
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Need help with code

    As you can see in your code there is no blipmode involved
    so why do you get the "*error* function AutoCAD variable setting rejected: "blipmode" nil" ?

    Because of that you have more functions and code in your AutoCAD environment that is not written with care.

    Your error handler at the crash point want to reset the systemvariable blipmode
    that is not the error handler in your code.

    Please read the Sticky: Anatomy of an AUTOLISP file in this forum
    especially my first, second and third beer.

    There is no linetype "bylayer" when making a layer, change to "Continuous" at line: 16


    : ) Happy Computing !


    kennet

    BTW your code in this post it is very unstable written, but it should work "if you walk the line" exactly as the code want, after changing line 16.

  7. #7
    100 Club
    Join Date
    2007-02
    Location
    Porto
    Posts
    107
    Login to Give a bone
    0

    Default Re: Need help with code

    Quote Originally Posted by kennet.sjoberg View Post
    There is no linetype "bylayer" when making a layer, change to "Continuous" at line: 16
    How can i bypass that? Oh my god...i was blind.
    Thank you!

Similar Threads

  1. Allow Other Code Compilers for ARX Code
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2013-02-10, 08:06 AM
  2. Insert vbscript code has not code
    By buzz in forum AMEP General
    Replies: 3
    Last Post: 2008-02-09, 03:08 AM
  3. Please help on this code
    By jitesh789 in forum AutoLISP
    Replies: 6
    Last Post: 2007-12-11, 05:55 PM
  4. Convert VBA code to VB code
    By Robert Platt in forum VBA/COM Interop
    Replies: 20
    Last Post: 2007-08-15, 10:13 PM

Posting Permissions

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