TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: R_rogerD on May 13, 2015, 07:39:30 AM

Title: Simple freebie help needed :-)
Post by: R_rogerD on May 13, 2015, 07:39:30 AM
Hi all,

I am totally new to writing programming for AutoCAD and in writing Lisps and Macros etc. I am attempting to write some of my own scripts from tutorials off of the Internet but it is a very slow process. I thought that I'd try for a little 'Freebie' help instead on here :-) No harm in asking eh? Hopefully, they are both really simple tasks with simple solutions.

Query 1:
I wish to click on a block and have it automatically rotate about it's insert point. The user then clicks on the second rotation point only.
IE 2x clicks of the mouse only. No acceptance click and no base point click. Currently, using standard ACad commands, requires 4x clicks with obs snaps on.

Query 2:
I wish to rotate and then move as a single operation. IE (normal Rotate command) - drag & select the object/s; right click to accept; point and click on base point; click on second rotation point but then..... (normal Move command but with objects remain selected); point and click for base point and then click for second displacement point. No specifics with regards object snapping.

If this request is considered too cheeky, I apologise. Hopefully, for someone who knows what they are doing, it will be a simple five minute task. :-)

Big thanks in advance.

Rroger_D
Title: Re: Simple freebie help needed :-)
Post by: Lee Mac on May 13, 2015, 08:53:21 AM
For Query 1:
Code: [Select]
(defun c:br ( / ent enx )
    (while
        (progn (setvar 'errno 0) (setq ent (car (entsel "\nSelect block: ")))
            (cond
                (   (= 7 (getvar 'errno))
                    (princ "\nMissed, try again.")
                )
                (   (null ent) nil)
                (   (/= "INSERT" (cdr (assoc 0 (setq enx (entget ent)))))
                    (princ "\nSelected object is not a block.")
                )
                (   t
                    (vl-cmdf "_.rotate" ent "" "_non" (trans (cdr (assoc 10 enx)) ent 1))
                    (while (= 1 (logand 1 (getvar 'cmdactive))) (vl-cmdf "\\"))
                    nil ;; exit loop
                )
            )
        )
    )
    (princ)
)

For Query 2: MOCORO :-)
Title: Re: Simple freebie help needed :-)
Post by: tedg on May 13, 2015, 03:50:57 PM
Lee....
You're awesome.


[beer]
Title: Re: Simple freebie help needed :-)
Post by: ribarm on May 13, 2015, 04:11:41 PM
I think this is faster than MOCORO...

http://www.theswamp.org/index.php?topic=40547.msg481693#msg481693
Title: Re: Simple freebie help needed :-)
Post by: R_rogerD on May 13, 2015, 05:41:27 PM
Hi,

Absolutely fabulous!!

I knew someone could do it easily enough. Great big thank yous..... :-)

I wasn't aware of the MOROCO command. I am now. Hopefully I can learn something from the way it has been written also.

Thanks for your comment ribarm. I did try the coding as per the link, although it seemed quite complicated. As with everything, I guess it is simple once you know how it works.

Thanks all.

Rroger_D
Title: Re: Simple freebie help needed :-)
Post by: Lee Mac on May 15, 2015, 04:43:54 AM
Lee....
You're awesome.

[beer]

Cheers Ted!  :-)

Absolutely fabulous!!

I knew someone could do it easily enough. Great big thank yous..... :-)

I wasn't aware of the MOROCO command. I am now. Hopefully I can learn something from the way it has been written also.

You're most welcome R_rogerD, happy to help  :-)