"Hotgrip" in Autolisp

"Hotgrip" in Autolisp

pr0pjer1005XXK7W
Observer Observer
883 Views
10 Replies
Message 1 of 11

"Hotgrip" in Autolisp

pr0pjer1005XXK7W
Observer
Observer

Hi,

 

I was wondering if it was possible to make Polyline Nodes "Hot" via Autolisp in AutoCAD 2022.

What I would do is something like prompting the User with the Rectangle Function and all Nodes inside the Rectangle are made "Hot" for the User to Interact with

 

0 Likes
884 Views
10 Replies
Replies (10)
Message 2 of 11

Moshe-A
Mentor
Mentor

@pr0pjer1005XXK7W  hi,

 

What is the purpose in doing this?

this could be done easily with whole objects (lines, arcs, circles - not plines)

 

Moshe

 

0 Likes
Message 3 of 11

john.uhden
Mentor
Mentor

@pr0pjer1005XXK7W ,

Years ago I wrote a routine run most entirely within a grread loop, and I was able to create pseudo-snaps with what I called glyphs using the grdraw or grvecs functions.  I suppose that system would work as pseudo-grips, but they would be only visible, not effectual.

I don't think that AutoLisp provides a way to hot-grip anything.  Probably need ARX programming.

John F. Uhden

0 Likes
Message 4 of 11

pr0pjer1005XXK7W
Observer
Observer

Thanks for your reply.

Without going into details, we got something new where we have to get a DXF and then change it in some weird way.

So if I change all Polylines into Lines it would be possible? If so can you give me an example?

0 Likes
Message 5 of 11

Kent1Cooper
Consultant
Consultant

@pr0pjer1005XXK7W wrote:

.... we have to get a DXF and then change it in some weird way. ....


Depending on the nature of that weird way you need to change it, it could well be doable with a Polyline without separating it into Lines, and maybe without needing to heat up grips for User on-screen interaction.  Can you give an example?

Kent Cooper, AIA
0 Likes
Message 6 of 11

Moshe-A
Mentor
Mentor

@pr0pjer1005XXK7W hi,

 

check this one, am i in the right direction?

insert the 2 attached blocks before running the lisp.

 

enjoy

Moshe

 

 

(defun c:hotgrip (/ _geometry _midpt _bscale ; local functions
		    ss0 ss1 scl ename lst i pi0 pt1)
 
 (setq _geometry (lambda (ent) (mapcar (function (lambda (item) (cdr item))) (vl-remove-if-not (function (lambda (item) (= (car item) 10))) (entget ent)))))
 (setq _midpt (lambda (p0 p1) (mapcar (function (lambda (x0 x1) (/ (+ x0 x1) 2))) p0 p1)))
 (setq _bscale (lambda (sz) (atof (rtos (/ (cadr sz) (car sz)) 2 2))))

 (setvar "cmdecho" 0)
 (command "._undo" "_begin")
  
 (if (and
       (setq ss0 (ssget ":s:e+." '((0 . "lwpolyline"))))
       (setq ss1 (ssget "_cp" (_geometry (ssname ss0 0)) '((0 . "lwpolyline"))))
     )
  (progn
   (ssdel (ssname ss0 0) ss1)
   (setq scl (_bscale (getvar "screensize")))

   (setq savColor (getvar "cecolor"))
   (setvar "cecolor" "yellow")

   (foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss1)))
    (setq lst (_geometry ename))

    (setq i 0 pt0 (nth i lst))
    (command "._insert" "sqrgrip" "_none" pt0 scl scl 0)
    (foreach pt1 (cdr lst)
     (command "._insert" "recgrip" "_none" (_midpt pt0 pt1) scl scl (angtos (angle pt0 pt1) 0 4))
     (command "._insert" "sqrgrip" "_none" pt1 scl scl 0)    
     (setq pt0 pt1)
    ); foreach
   ); foreach

   (setvar "cecolor" savColor)

   (if (setq ss1 (ssget "_wp" (_geometry (ssname ss0 0)) '((0 . "insert") (2 . "sqrgrip,recgrip"))))
    (command "._chprop" "_si" ss1 "_color" "red" "")
   )
  ); progn
 ); if

 (command "._undo" "_end")
 (setvar "cmdecho" 1)

 (princ)
); c:hotgrip

 

0 Likes
Message 7 of 11

john.uhden
Mentor
Mentor

@Moshe-A ,

Your code is very interesting.

Could you please post the two blocks in ACAD2000 format?  Thanks.

John F. Uhden

0 Likes
Message 8 of 11

Moshe-A
Mentor
Mentor

@john.uhden ,

 

sure 😀

 

 

0 Likes
Message 9 of 11

john.uhden
Mentor
Mentor

@Moshe-A ,

There's a problem there.

The code is designed to let you select just one object, but then it deletes the first (and only) object in the selection set.  Ergo, nothing happens.

John F. Uhden

0 Likes
Message 10 of 11

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

.... Could you please post the two blocks in ACAD2000 format? ....


[Get the free >DWG TrueView< program and you can quickly down-convert things yourself -- no waiting for a reply from the originator, and the Topic is spared a couple of excess Messages.]

Kent Cooper, AIA
0 Likes
Message 11 of 11

Moshe-A
Mentor
Mentor

@john.uhden ,

 

The code let you select the rectangle to ss0 than it runs another (setq ss1 (ssget "_cp")) to select what's inside and remove the rectangle from ss1. no other delete is made. works perfect for me on R2022. isn't it the  time john you move up from R2002? 😀

 

Now we are waiting for the OP to come back to see if i am in direction 🤣

 

Moshe

 

0 Likes