Lisp stopped working when moved from 2015 to 2016

Lisp stopped working when moved from 2015 to 2016

Anonymous
Not applicable
830 Views
2 Replies
Message 1 of 3

Lisp stopped working when moved from 2015 to 2016

Anonymous
Not applicable

Hi there. 

 

 My office recently moved to 2016 and a lisp that I have been using previously stopped working and I'm not sure why but I'm inclined to think is just a setting in 2016.  I have attached a copy of the Lisp routine as well as a screen shot of the command line during the command.  (The only other adjustment to the lisp would be each time I start the command it would place ortho on instead of off). 

 

I'm sure the fix is an easy one however elusive to me. 

 

I greatly appreciate your help in the past and now.  Makes a huge impact on my work speed.

 

thanks again.

 

 

 

 

;;;;;THIS ROUTINE IS TO PLACE 4x4 SHEAR POSTS AT THE END OF SELECTED SHEAR WALL LINE. REQUIRES LAYERS (S-PLAN-RCOL) TO EXIST AND PATHED TO BLOCK 4X6SHEARPOST

(defun C:4R  (/);(/ *error* doc svnames svvals esel ent edata pt1 pt2 side rot)
   (vl-load-com)
   (defun *error* (errmsg)
     (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
       (princ (strcat "\nError: " errmsg))
     ); if
     (mapcar 'setvar svnames svvals); reset System Variables
     (vla-endundomark doc)
     (princ)
   ); defun - *error*
   (setq doc (vla-get-activedocument (vlax-get-acad-object)))
   (vla-startundomark doc)
   (setq ; System Variable saving/resetting without separate variables for each:
     svnames '(osmode cmdecho orthomode blipmode clayer); list of System Variable Names
     svvals (mapcar 'getvar svnames); get initial Values
     esel (entsel "\nSelect Line at which to add Shear Posts: ")
     ent (car esel)
     edata (entget ent)
     pt1 (cdr (assoc 10 edata)); start
     pt2 (cdr (assoc 11 edata)); end
     side (getpoint pt1 "\nPick to side of Line on which to add shear posts: ")
     rot (* (/ (prin1 (angle (prin1 (vlax-curve-getClosestPointTo ent side T)) side)) pi) 180); ROTation angle for Insert commands
   ); setq
   (mapcar 'setvar svnames '(0 0 0 0 "s-plan-rcol"))
     ; turn off osnap, command echoing, ortho, blips; set Layer
   (command
     "_.insert" "4x4ShearPost"
       "_none" (polar pt1 (angle pt1 pt2) 1.75); half-post-width in from start
       "" "" rot
     "_.insert" ""
       "_none" (polar pt2 (angle pt2 pt1) 1.75); from other end
       "" "" rot
   ); command
   (mapcar 'setvar svnames svvals); reset System Variables
   (vla-endundomark doc)
   (princ)
 ); defun

 

 

 

 

 

Capture.PNG

0 Likes
831 Views
2 Replies
Replies (2)
Message 2 of 3

john.uhden
Mentor
Mentor

I didn't study all the code, but what popped out to me was your attempt to use the function vlax-curve-getClosestPointTo on an entity name.  That Active-X function can be used only on VLA objects, such as (setq object (vlax-ename->vla-object e)) to convert it.

 

Many of the Active-X functions allow you to access/modify objects much more deeply and easily than dealing with DXF codes.  Practice, practice.

 

To help you learn more about object properties, here's something I use all the time...

 

;; Command to "dump" ActiveX data of a non-nested object:
;;
(defun C:OD ()
  (and
    (setq e (car (entsel)))
    (setq object (vlax-ename->vla-object e))
    (vlax-dump-object object)
    (textscr)
  )
  (princ)
)

 

I did not localize the variables on purpose so that I could access them outside the function

John F. Uhden

0 Likes
Message 3 of 3

ВeekeeCZ
Consultant
Consultant

Try spoiler...

 

Spoiler
;;;;;THIS ROUTINE IS TO PLACE 4x4 SHEAR POSTS AT THE END OF SELECTED SHEAR WALL LINE. REQUIRES LAYERS (S-PLAN-RCOL) TO EXIST AND PATHED TO BLOCK 4X6SHEARPOST

(defun C:4R  (/);(/ *error* doc svnames svvals esel ent edata pt1 pt2 side rot)
   (vl-load-com)
   (defun *error* (errmsg)
     (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
       (princ (strcat "\nError: " errmsg))
     ); if
     (mapcar 'setvar svnames svvals); reset System Variables
     (vla-endundomark doc)
     (princ)
   ); defun - *error*
   (setq doc (vla-get-activedocument (vlax-get-acad-object)))
   (vla-startundomark doc)
   (setq ; System Variable saving/resetting without separate variables for each:
     svnames '(osmode cmdecho orthomode blipmode clayer); list of System Variable Names
     svvals (mapcar 'getvar svnames); get initial Values
     esel (entsel "\nSelect Line at which to add Shear Posts: ")
     ent (car esel)
     edata (entget ent)
     pt1 (cdr (assoc 10 edata)); start
     pt2 (cdr (assoc 11 edata)); end
     side (getpoint pt1 "\nPick to side of Line on which to add shear posts: ")
     rot (* (/ (prin1 (angle (prin1 (vlax-curve-getClosestPointTo ent side T)) side)) pi) 180); ROTation angle for Insert commands
     ip1 (polar pt1 (angle pt1 pt2) 1.75)
     ip2 (polar pt2 (angle pt2 pt1) 1.75)
   ); setq
   (mapcar 'setvar svnames '(0 0 0 0 "s-plan-rcol"))
     ; turn off osnap, command echoing, ortho, blips; set Layer
   (command
     "_.insert" "4x4ShearPost"
       "_none" ip1 ; half-post-width in from start
       "" "" rot
     "_.insert" ""
       "_none" ip2 ; from other end
       "" "" rot
   ); command
   (mapcar 'setvar svnames svvals); reset System Variables
   (vla-endundomark doc)
   (princ)
 ); defun
0 Likes