caditnow Posted September 10, 2015 Share Posted September 10, 2015 Hey all. I'm using AutoCAD 2016 and I'm trying to use the Homerun lisp below with no success. Others with older version of CAD are able to use. I'm hoping someone on this site will help me find a fix. (DEFUN C:HR (/ ORTM P1 P2 P3 AR AL RA P4 AN2 AN3 A3 AN P5 AN4 AR1) (SETQ ORTM (GETVAR "ORTHOMODE")) (SETVAR "ORTHOMODE" 0) (PROMPT "\nPICK POINT TO START FROM") (SETQ P1 (GETPOINT)) (PROMPT "\nPICK POINT FOR ARROW HEAD") (SETQ P2 (GETPOINT)) (COMMAND "ARC" P1 "E" P2 "D" PAUSE) (SETQ P3 (OSNAP P1 "QUI,MID")) (SETQ AR (ENTLAST)) (SETQ AL (ENTGET(ENTLAST))) (SETQ RA (CDR (ASSOC 40 AL))) (SETQ P4 (CDR (ASSOC 10 AL))) (SETQ AN2 (ANGLE P4 P2)) (SETQ AN3 (ANGLE P4 P3)) (SETQ A3 (ANGLE P4 P3)) (SETQ AN (ANGLE P1 P2)) (COND ((OR (> AN (* PI 1.5)) ( (IF (AND (> A3 0.0) ( (SETQ AN2 (ANGLE P4 P2)) (SETQ AN2 (ANGLE P2 P4)) ) ) ((AND ( AN (* PI 0.5))) ;;;Modifications were done (IF (AND (> A3 0.0) ( (SETQ AN2 (ANGLE P2 P4)) (SETQ AN2 (ANGLE P4 P2)) ) ) ) (SETQ P5 (POLAR P2 (+ AN2 (* PI 0.5)) (* 0.15 (GETVAR "DIMSCALE")))) (SETQ AN4 (ANGLE P4 P5)) (SETQ P5 (POLAR P4 AN4 RA)) (COMMAND "PLINE" P2 "W" "0" (* 0.06 (GETVAR "DIMSCALE")) P5 "W" "0" "0" P2 "") (SETQ AR1 (ENTLAST)) (COMMAND "PEDIT" AR "Y" "J" AR1 "" "X") (setq ar(entlast)) (SETVAR "ORTHOMODE" ortm) ) Quote Link to comment Share on other sites More sharing options...
iconeo Posted September 10, 2015 Share Posted September 10, 2015 Please post code properly in the future. What error message gets thrown? Quote Link to comment Share on other sites More sharing options...
caditnow Posted September 10, 2015 Author Share Posted September 10, 2015 sorry about the bad pasting. the error i'm getting is: Specify center point of arc (hold Ctrl to switch direction) or [Angle/Direction/Radius]: D Specify tangent direction for the start point of arc (hold Ctrl to switch direction): Command: ; error: bad argument type: 2D/3D point: nil I tried debugging this with vlisp and it seemed to fail on line: (SETQ AN3 (ANGLE P4 P3)) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 10, 2015 Share Posted September 10, 2015 (edited) osnap is a reserved word lisp is looking for a defun here (SETQ P3 (OSNAP P1 "QUI,MID")) ;wrong (SETQ P3 (GETPOINT P1 "QUI,MID")) ;works Edited September 11, 2015 by BIGAL Quote Link to comment Share on other sites More sharing options...
caditnow Posted September 10, 2015 Author Share Posted September 10, 2015 thank you BIGAL, but I must be doing something wrong. I replaced (SETQ P3 (OSNAP P1 "QUI,MID")) with (SETQ P3 (GETPOINT P1 "QUI,MID")) but still no luck. Were you able to try this in ACAD 2016? Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted September 10, 2015 Share Posted September 10, 2015 BIGAL, this is wrong : (setq p3 (getpoint p1 "QUI,MID")) as string after point specification only represents message and not OSNAP-s... Instead try to (setvar 'OSMODE num) before call of (getpoint) or set OSNAP-s with command directly before (getpoint) : (command "_.OSNAP" "QUI,MID") M.R. Quote Link to comment Share on other sites More sharing options...
caditnow Posted September 10, 2015 Author Share Posted September 10, 2015 thank you M.R. I'm not good at lisp so I'm not sure exactly how you're modifying the lisp. would you mind posting a before and after of the portions you are modifying? Quote Link to comment Share on other sites More sharing options...
David Bethel Posted September 10, 2015 Share Posted September 10, 2015 (SETQ P3 (OSNAP P1 "QUI,MID")) Should work IF p1 is a valid point list on an entity that the midpoint can be extracted from and within the current pickbox aperture size. Otherwise (osnap) will return nil and should ' error: bad argument type: 2D/3D point: nil ' to any function requiring a point list value parameter. ie (angle) -Davud Quote Link to comment Share on other sites More sharing options...
jvillarreal Posted September 10, 2015 Share Posted September 10, 2015 Just use another method to get your midpoint. Here's one way: (DEFUN C:HR (/ ORTM P1 P2 P3 AR AL RA P4 AN2 AN3 A3 AN P5 AN4 AR1) (SETQ ORTM (GETVAR "ORTHOMODE")) (SETVAR "ORTHOMODE" 0) (PROMPT "\nPICK POINT TO START FROM") (SETQ P1 (GETPOINT)) (PROMPT "\nPICK POINT FOR ARROW HEAD") (SETQ P2 (GETPOINT)) (COMMAND "ARC" P1 "E" P2 "D" PAUSE) [color="red"](SETQ P3 (POLAR P1 (ANGLE P1 P2)(/ (DISTANCE P1 P2) 2.0)))[/color] ;(SETQ P3 (OSNAP P1 "QUI,MID")) (SETQ AR (ENTLAST)) (SETQ AL (ENTGET(ENTLAST))) (SETQ RA (CDR (ASSOC 40 AL))) (SETQ P4 (CDR (ASSOC 10 AL))) (SETQ AN2 (ANGLE P4 P2)) (SETQ AN3 (ANGLE P4 P3)) (SETQ A3 (ANGLE P4 P3)) (SETQ AN (ANGLE P1 P2)) (COND ((OR (> AN (* PI 1.5)) (< AN (* PI 0.5))) (IF (AND (> A3 0.0) (< A3 PI)) (SETQ AN2 (ANGLE P4 P2)) (SETQ AN2 (ANGLE P2 P4)) ) ) ((AND (< AN (* PI 1.5)) (> AN (* PI 0.5))) ;;;Modifications were done (IF (AND (> A3 0.0) (< A3 PI)) ;;;here (SETQ AN2 (ANGLE P2 P4)) (SETQ AN2 (ANGLE P4 P2)) ) ) ) (SETQ P5 (POLAR P2 (+ AN2 (* PI 0.5)) (* 0.15 (GETVAR "DIMSCALE")))) (SETQ AN4 (ANGLE P4 P5)) (SETQ P5 (POLAR P4 AN4 RA)) (COMMAND "PLINE" P2 "W" "0" (* 0.06 (GETVAR "DIMSCALE")) P5 "W" "0" "0" P2 "") (SETQ AR1 (ENTLAST)) (COMMAND "PEDIT" AR "Y" "J" AR1 "" "X") (setq ar(entlast)) (SETVAR "ORTHOMODE" ortm) ) Quote Link to comment Share on other sites More sharing options...
caditnow Posted September 10, 2015 Author Share Posted September 10, 2015 jvillarreal YOU ROCK!!!! Thank you very much. This script works perfectly in ACAD 2016. Again YOU ROCK!!! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 11, 2015 Share Posted September 11, 2015 The way a few of us would have tackled it. (SETVAR "ORTHOMODE" 0) (setq oldsnap (getvar "osmode")) ......... ........ (setvar "osmode" 1026) ; this is qui mid (SETQ P3 (getpoint P1 "Pick next point")) (setvar "osmode" oldsnap) ; snaps back to what they were ........ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.