Author Topic: Add Mirror Option  (Read 5570 times)

0 Members and 1 Guest are viewing this topic.

Oak3s

  • Guest
Add Mirror Option
« on: October 22, 2010, 06:33:20 PM »
Over time I have been able to put the following together. It doesnt account for errors at this point. What it does do is draw a rectangle that is 0.5 tall. It asks for a width. I use acet-ss-drag-move so that a user can see where it will be placed before the point is selected.
I would appreciate some help as to how to add a mirror option. The idea would be to hit spacebar and the vector from acet-ss-drag-move would mirror/flip about the Y axis.
Any ideas.
Code: [Select]
(defun c:Plate (/ Thick Wide tPT PT1 PT2 PT3 InsPT ss)
(defun DTR (A) (* pi (/ A 180.0)))
(setvar "CMDECHO" 0)
(setvar "OSMODE" 0)
(setq Thick 0.5
     Wide (getint "\nEnter Plate Width in Inches: ")
     tPT (list 0. 10000. 0.)
     PT1 (polar tPT (DTR 90) Thick)
     PT2 (polar PT1 (DTR 0) Wide)
     PT3 (polar PT2 (DTR 270) Thick)
)
(vl-cmdf "pline" tPT PT1 PT2 PT3 tPT "")
(setq ss (ssadd))
(ssadd (entlast) ss)
(setq InsPT (acet-ss-drag-move ss tPT "\nSelect base point: " ))
(vl-cmdf "_.Move" ss "" tPT InsPT)
(princ)
)
*Edited by Oak3s 10.22.10

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Add Mirror Option
« Reply #1 on: October 22, 2010, 06:36:01 PM »
What version of CAD are you on? This a task easily accomplished with a dynamic block.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Oak3s

  • Guest
Re: Add Mirror Option
« Reply #2 on: October 22, 2010, 06:41:42 PM »
v2011

I looked at doing this by inserting a DB yesterday but I havent gotten back to that today. This is how I have been doing it and just started exploring the DB idea.
My idea was 'I can follow this code pretty well...I have to look up every line of Visual LISP and so far the options I have found for modifying a DB have been VL. I am getting there but my big hangup has been trying to get the name through (entlast) rather than (entsel)...I will find the code to give you a better idea of what I am talking about. I believe it was Lee Mac and T.Willey I was getting info from.

Oak3s

  • Guest
Re: Add Mirror Option
« Reply #3 on: October 22, 2010, 06:46:52 PM »
The following basically came from T.Willey
http://www.theswamp.org/index.php?topic=31549.0
All I added was the function call, vl-load-com, and set the object to ob2.
Other than that I tried to change the property to "Width" and the value to 6...but no go.
Code: [Select]
(defun c:dyn (/)
(vl-load-com)
(setq ob2 (vlax-ename->vla-object(car(entsel))))
(foreach i
(vlax-invoke-method ob2 'getdynamicblockproperties)
(if (= "Width" (vla-get-PropertyName i))
        (vla-put-Value i 6)
)
)
)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Add Mirror Option
« Reply #4 on: October 22, 2010, 07:00:29 PM »
I posted in the thread linked to, so if that doesn't help you, let us know.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Oak3s

  • Guest
Re: Add Mirror Option
« Reply #5 on: October 22, 2010, 07:14:28 PM »
I noticed. Thank you.

I would be just as satisfied to have this method allow for a mirror option though. Either way I will learn something :)

Oak3s

  • Guest
Re: Add Mirror Option
« Reply #6 on: October 22, 2010, 10:21:17 PM »
What version of CAD are you on? This a task easily accomplished with a dynamic block.

Could you elaborate?

Insert block at some crazy point.
Then acet-ss-drag-move and have the option
to hit spacebar to 'flip' it?

or

insert block (visually see it at cursor) and flip it while it is actually there?

The goal is to see the entity before selecting its point.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Add Mirror Option
« Reply #7 on: October 23, 2010, 12:23:04 PM »
What version of CAD are you on? This a task easily accomplished with a dynamic block.

Could you elaborate?

Insert block at some crazy point.
Then acet-ss-drag-move and have the option
to hit spacebar to 'flip' it?

or

insert block (visually see it at cursor) and flip it while it is actually there?

The goal is to see the entity before selecting its point.

Give this block a try .. might be able to help out some more later.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Add Mirror Option
« Reply #8 on: October 25, 2010, 05:41:18 PM »
Did this block not work for you?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Oak3s

  • Guest
Re: Add Mirror Option
« Reply #9 on: October 26, 2010, 01:07:32 PM »
The block works nicely. However my options on insert are to scale and/or rotate. The block itself can flip but I would like the option during insert (or a modified version of insert).

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Add Mirror Option
« Reply #10 on: October 26, 2010, 03:15:57 PM »
See if this works how you want ... this is how I'd approach what I think you want (I'd still use a block):


Code: [Select]
(defun c:plate (/ ce e el h w xs)
  (defun mkblk ()
    (and (not (tblobjname "block" "square"))
(entmake '((0 . "BLOCK")
    (100 . "AcDbEntity")
    (8 . "0")
    (100 . "AcDbBlockReference")
    (2 . "square")
    (10 0.0 0.0 0.0)
    (70 . 0)
   )
)
(entmake '((0 . "LWPOLYLINE")
    (100 . "AcDbEntity")
    (8 . "0")
    (100 . "AcDbPolyline")
    (90 . 4)
    (70 . 129)
    (43 . 0.0)
    (10 0.0 1.0)
    (10 0.0 0.0)
    (10 1.0 0.0)
    (10 1.0 1.0)
   )
)
(entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
    )
  )
  (if (and (setq w (getdist "\nEnter Plate Width in Inches: "))
   (setq h 0.5)
   (setq ce (getvar 'cmdecho))
   ;;(setq hgt (getdist "\nEnter Plate Height in Inches: "))
      )
    (progn (mkblk)
   (setvar 'cmdecho 0)
   (vl-cmdf ".-insert" "square" "X" w "Y" h "R" 0.0 pause)
   (if (and (setq e (entlast))
    (setq el (entget e))
    (= (cdr (assoc 2 el)) "square")
    (equal (cdr (assoc 10 el)) (getvar 'lastpoint))
       )
     (while (getpoint "\nPick a point to flip plate or enter to end: ")
       (setq xs (assoc 41 el))
       (setq el (entmod (subst (cons 41 (- (cdr xs))) xs el)))
     )
   )
   (setvar 'cmdecho ce)
    )
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Oak3s

  • Guest
Re: Add Mirror Option
« Reply #11 on: October 26, 2010, 04:41:33 PM »
that works really well but it doesnt off the 'flip' when I would like it to be offered. I appreciate the code and I am not asking someone to write it for me. I just dont know where to start.

You know when you insert a block and the comman line reads:
Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]

I would like it to read with the options of:
[Rotate/Flip] and have flip be initiated by just hitting spacebar. This all takes place before specifying the insertion point.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Add Mirror Option
« Reply #12 on: October 26, 2010, 05:30:43 PM »
The flip can be added in a grread loop before the block is placed but I would not go that route for lack of snaps. The more I travel down the rabbit hole the more I'm convinced a dynamic block would be the answer.

You have a sample drawing?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Oak3s

  • Guest
Re: Add Mirror Option
« Reply #13 on: October 26, 2010, 05:52:06 PM »
When you say a dynamic block would be the answer are you referring to the functionality after the block is placed or before?

Either way the end product will be just lines. At the moment company standard is entities such as this are not blocks. It can be a block to place it (so the functionality of inserting is used) but after that it will be plines.

I apologize if I am missing something...I sure feel like I am because I am repeating myself a lot :).

Also...I may be missing something when I insert a DB. I looks to me like the same options are available when inserting a regular block or a DB...do you have the DB properties available to you?

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Add Mirror Option
« Reply #14 on: October 26, 2010, 06:03:11 PM »
The dynamic block has the functionality after it is placed (but there are a lot of cool quick editing features).

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC