Hi All,
I have a simple routine that used to work as a transparent command. It finds the centroid of a bunch of selected points. I used to be able to transparently use this during the line command. While in the line command, I could select other snap points around the drawing and the program would find the point at the centroid of my selection and continue the line command to that point. I could use the command at any time while drawing lines. Now with 2022, if I start the line command and then immediately run the program, the start point of my line will be the centroid as expected. However, if I have started to draw the line and am attempting to select the next point, the program seems turn of the cursor, turn off the rubber-band line, does not appear to snap to anything, but the coordinates in the status bar update. When exiting out of the transparent command, the line comes back alive from some random point I can not verify...it might be the centroid of random picks on the screen, but I can't tell what I've picked.
Have any system variables changed that affect this behavior? Or, is this method of programming just obsolete?
AutoCAD 2022 on Windows 10 Pro 64 bit.
Solved! Go to Solution.
@JoeHoffmayer wrote:
... the line comes back alive from some random point I can not verify...it might be the centroid of random picks on the screen, but I can't tell what I've picked.
It appears to be working fine on my initail test though there could be some improvements. But so you know, To be honest i dont have an idea as far as what "works" really means.
Does it work on a lower version as expected with the same scenario or file?
If you are actively in the line command and run this as a transparent command, and be able to continue selecting points on the screen in order to find the centroid for the next point of the line, then it "works" as intended. It's an old program I quickly wrote to be able to simply put something at the imaginary center of several points.
When I'm running the transparent command, my screen simply stops showing me feedback of where the mouse is...I can tell the mouse has moved because the coordinates update, but there is nothing showing on the screen, and I have no control of the points I select...snap, or otherwise...so for me it does not "work".
Thank you for checking it out and reporting back to the forum. If there is no obvious variable or improper use of the getpoint command, then I suspect this may be a graphics card problem on my end.
Forgot to answer the second part...
Yes, this has worked on every version of Autocad I've had since 1998.
This is a new problem for me since updating to 2022.
if the poyline already exists, then
;; (princ (LM_PolyCentroid (car (entsel)))
Very good solution.. you concat two function
;;(princ (LM_PolyCentroid (dfn_getandmake_polyline)))
(Defun c:opl (/ $rr)
(Defun dfn_getandmake_polyline( / $rr ptc idx strm pix)
(princ "\nYou create on -polyline")
(setq idx 0);;This solution not tested-yet. I enter from mySmarthpne with Android
(command "_pline")
(setq $rr (entlast))
(setq ptc (getpoint "\n Give me point0:"))
(while ptc
(setq pix (strcat (rtos (car ptc) 2 4) "," (rtos (cadr ptc) 2 4)))
(command pix)
(setq idx (1+ idx))
(setq strm (strcat "\nGive me point" (itoa idx) ":"))
(prompt strm)
(setq ptc (getpoint ptc))
(setq pix (if ptc (strcat (rtos (car ptc) 2 4) "," (rtos (cadr ptc) 2 4)) nil))
(if pix (command pix))
);;off-while
(if (/= $rr (entlast)) (setq $rr (entlast)) (setq $rr nil))
$rr)
Thank you for the reply and the code. I should note that my little program is not specifically and only for drawing a line to the centroid of a group of picked points, it can really be used like an osnap when in any command that is placing an entity. It used to work for everything; inserting blocks, drawing lines, plines, etc.
I worked at it a bit and discovered the problem is with the getpoint command. It simply turns off the rubber band line if I'm in a command and makes moving about the screen impossible to coordinate. Once a point is picked from the getpoint command, the rubber band line comes back alive.
This occurs if a command is active. If there is no command active and I run a getpoint from lisp, the cursor stays on the screen and I can use snaps to coordinate where I'm picking.
The problem appears to be somehow related to what the cursor is doing during a transparent command and my graphics card...NVIDIA GeForce MX450 27.21.14.6230 DirectX 12.
Are there variables to control the cursor during selection?
I don't know if there's some new variable that controls input during a command, but
since you are drawing only lines, your code could terminate the current line command, use your average thingy to get the next point and resume the line command by calling (getvar "lastpoint") for where you had temporarily terminated.
John F. Uhden
The routine used to work for any input...so not just drawing lines. I could be in the process of inserting blocks and choose the routine from an icon and it would go into the selection process to find the midpoint between several snaps, then place the block at the calculated point. It worked great. It was actually an expansion of a MIDPOINT routine that would find the midpoint between two snaps. I kept the midpoint routine and assigned it to an icon, then made the centroid routine by expanding the selection to as many picks as you want. Both lisp routines worked perfectly until I got a new computer and updated to AutoCAD 2022. Not sure it's AutoCAD, but possibly the graphics card.
I did completely change the MIDPOINT routine to use the actual built in function in AutoCAD...that works transparently.
I will take your suggestion and try to build a list, find the average x,y and z point, and set that to lastpoint. That should work. Need a few days to get around to it. Thanks for the suggestion.
possibly a 'feature' of my graphics card also...using a laptop for CAD...not the best graphic situation
@JoeHoffmayer wrote:
possibly a 'feature' of my graphics card also...using a laptop for CAD...not the best graphic situation
I don't think it's your card .. I have a fairly stout Nvidia Quadro and get the same results here. ;/
Here's another way to get those points .. there is definitely a display bug in 2022.
(defun c:foo (/ _vx ap aps p)
(defun _vx (pt clr / a vs)
(setq a (/ pi 4.)
vs (* 0.025 (getvar 'viewsize))
)
(repeat 4 (grdraw pt (polar pt (setq a (+ a (/ pi 2.))) vs) clr))
(princ)
)
(defun _ap (pl) (mapcar (function (lambda (x) (/ x (length pl)))) (apply 'mapcar (cons '+ pl))))
(while (setq p (getpoint "\nPick points to average: "))
(redraw)
(setq aps (cons p aps))
(_vx (setq ap (_ap aps)) 3)
(foreach x aps (grdraw ap x 8))
)
ap
)
Thank you for your code.
I tried it and still my screen drops the cursor when looking to pick points.
I tried changing DNYMODE, and no difference...so, I'm going to put this on the back burner for now and get some work done. I will pick this up again when I get inspired.
Thank you all - appreciate all the help.
In AutoCAD 2022 (up through update 2022.1), if system variable LISPSYS is set to 0 (mode for legacy Visual LISP IDE) then display will freeze when AutoLISP function getpoint, getorient, getdist, getangle, getint or getreal are executed transparently at prompt for second point with commands such as LINE, PLINE, MOVE, COPY, ROTATE, etc. Workaround is to set LISPSYS to 1 (mode for Visual Studio IDE) and restart AutoCAD. Issue occurs with ActiveX methods for getting input as well, such as GetPoint.
Thanks for the reply. I got excited. I see my Lispsys is 1 - and it doesn't rubberband the cursor when picking points.
I thought to toggle the variable to 0...no change. Back to 1...still no change.
I wish this was it. In fact, that is what I expected it to be...some sort of variable that effects the graphics but not the function. Keep in mind - the program does find the mid point (I actually have another version that finds the centroid of several selection picks that works too) except you can't see what you are selecting. Which means the program does not work.
Thanks again,
Back to the drawing board...
Hold on - it was set to 1 when I checked...and not working. I've been working with LISPSYS set to 1 for who knows how long. Based on your suggestion, I toggled it to zero and restarted autocad and it didn't work. (which we might have expected). Then toggled it back to 1. I didn't restart it again.
After a new restart it works! I get the osnaps (not a rubber band) but that is just fine. You need to see what you snap to in order to get a centroid between the picks.
IT WORKS!!!! YES! Thank you!
Best wishes - Joeh
Can't find what you're looking for? Ask the community or share your knowledge.