Author Topic: Lisp to Insert a block and then mirror it so that it's X value is -1  (Read 219 times)

0 Members and 1 Guest are viewing this topic.


  • Mosquito
  • Posts: 7

Hi All

Start Preface -
I'm having trouble with some lisp programming. I DID have a great manual on lisp programming that slow walked you through how to do various things, it came out back when Autocad still produced hard copy manuals with their releases (2002-2008?), so it was a while ago.
Now I can't find that blasted manual (I think that I lent it out to someone and they didn't return it).
Anyway, I can remember that it made a big deal of associate numbers and how to manipulate them to your advantage in lisps, converting to strings, angles in radians, etc.

Does anyone know if the old lisp manuals that were available with Acad. I found the 2013 version, the one that I am after was before 2013.
Failing that what is a nice, quick & dirty way of (re)learning simple Lisp programing (with examples)?
- End Preface

I have a lisp where I select an insertion point and insert a block at that point, put the block on a specific layer and change the visibility state to the one that I want.

So far, so good.

Now what I want to do is what I've described above (insert the block at a selected insertion point, change the layer & the visibility state) then mirror the block.
I know that when I want to mirror the block I can just select "last"
I know that the initial insertion point (assoc 10 & assoc 20) of the block will give me my first X, Y point for a mirror command
I know that I can pull apart the initial Y value of the insertion point add 10 to that value and have a second X, Y point for the mirror command. I don't have access to my old manual that walked me through the process of doing this.

Can someone please help me.

Copy of my circuit breaker lisp (visibility state change cribbed from Lee Mac) that I want to add the mirror change at the end of;


;;;;; Collect OSMODE settings
(setq COSM (getvar 'osmode))
(setq ATD (getvar 'attdia))
(setq ATR (getvar 'attreq))

(setq COSM (getvar 'osmode))
(setvar 'osmode 544)
(setvar 'attdia 0)
(setvar 'attreq 0)

;;;;; Collect current LTscale value and create Values for SC
(setq LTS (getvar 'LTSCALE))
(setq SC (* 0.001 LTS))

;;;;; Insert BLOCK ;;;
(command "insert" "Sch Breaker" PAUSE SC SC PAUSE "")
(command "change" "l" "" "p" "la" "SCHEM" "")

;;;;; Return OSMODE to original values
(setvar 'osmode COSM)
(setvar 'attdia ATD)
(setvar 'attreq ATR)

;;;;; change visibility state
(defun CHGDYNPROP (Ename propname newval /  lo obj v vval sal tot i)
       ;; Changes a given variable in your block
       ;; Passed: Ename, Property Name, New value for Property
       (setq obj (if (= (type Ename) 'vla-object)
    (vlax-ename->vla-object Ename))
     v (vla-getdynamicblockproperties obj)
     vval (vlax-variant-value v)
     sal (vlax-safearray->list vval)
     tot (length sal)
     i 0)
       (while (< i tot)
         (if (= (vlax-get-property (nth i sal) "PropertyName") propname)
             (vlax-put-property (nth i sal) "Value" newval)
             (setq i tot)
           (setq i (1+ i))
(CHGDYNPROP (entlast) "Visibility1" "Circuit Breaker Single Phase") ;Circuit Breaker Single Phase is the visibility state name


  • Swamp Rat
  • Posts: 1171
  • 40 + years of using Autocad
Re: Lisp to Insert a block and then mirror it so that it's X value is -1
« Reply #1 on: March 14, 2023, 07:58:51 PM »
I have 4 manuals all different, Lisp, Customising Autocad, Extras etc R12 version sorry you can not have them. Yes refer to them often.

Kindle has some good books cheap. You can still go to Autocad help just need correct link think developer will try to find.

A man who never made a mistake never made anything


  • Mosquito
  • Posts: 7
Re: Lisp to Insert a block and then mirror it so that it's X value is -1
« Reply #2 on: March 18, 2023, 11:01:49 PM »
Thanks for your help BigAl


  • Bull Frog
  • Posts: 478
Re: Lisp to Insert a block and then mirror it so that it's X value is -1
« Reply #3 on: March 26, 2023, 12:04:50 PM »
Hi Sisyphus, please give it a try.

It use the VLA-MIRROR

from the  selected mirror line

Code: [Select]
Location @ Córdoba Argentina Using ACAD 2019  at Window 10