Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Coding help

  1. #1
    I could stop if I wanted to cadd4la's Avatar
    Join Date
    2001-12
    Location
    Newport Beach, CA
    Posts
    399
    Login to Give a bone
    0

    Question Coding help

    Hello everyone,

    I need a little help to get this code to work.

    Thanks,

    Code:
    (DEFUN C:PLC2P(/ *error* useros usercmd)
    ;; error function & Routine Exit
       (DEFUN *error* (msg)
         (IF
           (NOT
         (MEMBER
           msg
           '("console break"
             "Function cancelled"
             "quit / exit abort"
             ""
            )
         ) ;_ end of member
           ) ;_ end of not
            (PRINC (STRCAT "nError: " msg))
         ); endif
         ;;reset all variables here
         (IF    useros
           (SETVAR "osmode" useros)
         ) ;_ end of if
         (IF    usercmd
           (SETVAR "CMDECHO" usercmd)
         ) ;_ end of if
         (SETQ useros nil
           usercmd nil
         ) ;_ end of setq
       );end error function  (defun *Error* (msg) ; embedded defun
     
       (SETQ    useros    (GETVAR "osmode")
         usercmd    (GETVAR "CMDECHO")
       ) ;_ end of setq
    (SETVAR "CMDECHO" 0)
    (SETQ os1 (GETVAR "osmode"))
    (princ "\nPLINE FROM CENTER TO PERPENDICULAR:")    
    ;;(setq ossnap (getvar "osmode"))
            
    (SETVAR "OSMODE" 4);;
    <--- CENTER OSNAP       
    (SETQ PT1 (GETPOINT "PICK FIRST POINT"))
            
    (SETVAR "OSMODE" 128)
    ;;
    <--- PERPENDICULAR OSNAP        
    (SETQ PT2 (GETPOINT PT1 "PICK SECOND POINT"))
            
    (SETVAR "OSMODE" 0)
               
    (COMMAND "_PLINE" PT1 "perp" PT2 )
        
    ;;(setvar "osmode" ossnap)
    
    (SETVAR "osmode" os1)
    (SETVAR "CMDECHO" 1)        
    (princ)
    
     ) ;_ end of DEFUN

  2. #2
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    Default Re: Coding help

    Theres, nothing wrong with the code itself. except where you place the comments

    Code:
    (SETVAR "OSMODE" 4);; <--- CENTER OSNAP       
    (SETQ PT1 (GETPOINT "PICK FIRST POINT"))
            
    (SETVAR "OSMODE" 128)
    ;; <--- PERPENDICULAR OSNAP

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Coding help

    Compare this:
    Code:
    (defun c:FOO1 ()
      (command "._pline" "_cen" pause "_perp" pause "")
      (princ)
    )

    ... To this:
    Code:
    (vl-load-com)
    
    (defun c:FOO2 (/ *error* startPoint endPoint oldCmdecho oldOsmode)
    
      (defun *error* (msg)
        (and oldCmdecho (setvar 'cmdecho oldCmdecho))
        (and oldOsmode (setvar 'osmode oldOsmode))
        (cond ((not msg))                                                   ; Normal exit
              ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
              ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
        )
        (princ)
      )
    
      (if
        (and
          (setq oldOsmode (getvar 'osmode))
          (setvar 'osmode 4)
          (setq startPoint (getpoint "\nSpecify first point: "))
          (setvar 'osmode 128)
          (not (initget 32))
          (setq endPoint (getpoint startPoint "\nSpecify second point: "))
        )
         (progn
           (setq oldCmdecho (getvar 'cmdecho))
           (setvar 'cmdecho 0)
           (command "._pline" "_non" startPoint "_perp" endPoint "")
         )
      )
      (*error* nil)
    )
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Coding help

    Quote Originally Posted by pbejse View Post
    Theres, nothing wrong with the code itself. except where you place the comments
    Tisk, tisk, pbejse... Consider pt1 == Nil
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  5. #5
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    Default Re: Coding help

    Quote Originally Posted by BlackBox View Post
    Tisk, tisk, pbejse... Consider pt1 == Nil
    Of course BlackBox... just point out the obvious error and most probably the reason why it doesn't work for cadd4l at all.

    But you're right... been lazy this past few days to even suggest the proper coding habits.

    Thank you nevertheless for pointing that out... I deservedit i guess

    Cheers

  6. #6
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Coding help

    Quote Originally Posted by pbejse View Post
    Of course BlackBox... just point out the obvious error and most probably the reason why it doesn't work for cadd4l at all.

    But you're right... been lazy this past few days to even suggest the proper coding habits.

    Thank you nevertheless for pointing that out... I deservedit i guess

    Cheers
    I'm only ribbing you, because you have much knowledge.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  7. #7
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    Default Re: Coding help

    Quote Originally Posted by BlackBox View Post
    I'm only ribbing you, because you have much knowledge.
    Thank you BlackBox. None taken. I've been busy brushing up on my 3D and rendering skills this past few weeks since i contracted a small project that requires that set of skills.

    cheers

  8. #8
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Coding help

    Quote Originally Posted by pbejse View Post
    Thank you BlackBox. None taken. I've been busy brushing up on my 3D and rendering skills this past few weeks since i contracted a small project that requires that set of skills.

    cheers
    We'll have to chat elsewhere... My background is actually in Computer Animation using Maya; character modeling, texturing, lighting, rigging, animating, rendering, etc..

    /OffTopic
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  9. #9
    I could stop if I wanted to cadd4la's Avatar
    Join Date
    2001-12
    Location
    Newport Beach, CA
    Posts
    399
    Login to Give a bone
    0

    Default Re: Coding help

    BlackBox,

    Thanks for the help, but the code is not resetting if I click on the ESC key.

  10. #10
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Coding help

    Quote Originally Posted by cadd4la View Post
    ... the code is not resetting if I click on the ESC key.
    It works just fine on my end... What is not resetting, exactly?
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Page 1 of 2 12 LastLast

Similar Threads

  1. Suggested Guidelines for Coding
    By peter in forum AutoLISP
    Replies: 12
    Last Post: 2015-07-27, 08:06 AM
  2. Coding help
    By cadd4la in forum AutoLISP
    Replies: 2
    Last Post: 2013-07-08, 10:50 PM
  3. Coding help.
    By cadd4la in forum AutoLISP
    Replies: 5
    Last Post: 2012-04-14, 02:58 AM
  4. CODING ELEMENTS
    By Steve Hutana in forum Revit - Platform
    Replies: 2
    Last Post: 2009-08-09, 08:42 PM
  5. Color Coding XYZ in iProperties Tab
    By inventor.wishlist1738 in forum Inventor Wish List
    Replies: 0
    Last Post: 2006-06-14, 04:07 AM

Posting Permissions

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