Author Topic: Reverse polygon  (Read 3270 times)

0 Members and 1 Guest are viewing this topic.

walesas

  • Guest
Reverse polygon
« on: December 15, 2014, 02:46:01 PM »
Hi,
I have problem with reversing polygon about center point.I need to have 2 polygons with 1 base point,but each polygon must be in opposite direction.Here`s my code so far:

Code: [Select]
(defun c:Zvaigzde ()
  (vl-cmdf
    "._Polygon"
    "3"
    (getpoint "\Specify center of polygon: ")
    "_C"
    (* (getreal "\nEnter diameter: ") 0.5)
  )
(princ)
)

P.S Polygon is triangle,so figure must look like star

ymg

  • Guest
Re: Reverse polygon
« Reply #1 on: December 15, 2014, 06:22:45 PM »
You simply need to mirror your polygon.

ymg

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Reverse polygon
« Reply #2 on: December 16, 2014, 12:24:58 AM »
One way with command calls .

Code: [Select]
(defun c:foo (/ e p o)
  (setq e (entlast))
  (vl-cmdf
    "._Polygon"
    "3"
    (setq p (getpoint "\Specify center of polygon: "))
    "_C"
    (* (getreal "\nEnter diameter: ") 0.5)
  )
  (if (and (not (eq e (setq o (entlast))))
           (eq (cdr (assoc 0 (entget o))) "LWPOLYLINE")
      )
    (command "_.rotate" o "" "_none" p "_c" 180.)
  )
  (princ)
)

walesas

  • Guest
Re: Reverse polygon
« Reply #3 on: December 16, 2014, 03:44:26 AM »
One way with command calls .

Code: [Select]
(defun c:foo (/ e p o)
  (setq e (entlast))
  (vl-cmdf
    "._Polygon"
    "3"
    (setq p (getpoint "\Specify center of polygon: "))
    "_C"
    (* (getreal "\nEnter diameter: ") 0.5)
  )
  (if (and (not (eq e (setq o (entlast))))
           (eq (cdr (assoc 0 (entget o))) "LWPOLYLINE")
      )
    (command "_.rotate" o "" "_none" p "_c" 180.)
  )
  (princ)
)

Thanks,it`s exactly what I need

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Reverse polygon
« Reply #4 on: December 16, 2014, 05:23:28 AM »

Thanks,it`s exactly what I need

You are welcome .

walesas

  • Guest
Re: Reverse polygon
« Reply #5 on: December 16, 2014, 12:18:02 PM »
Hello,
Sorry for asking,but maybe someone could help with my university task and write lisp code? Tommorow I will get score for this work,so now you are my only hope.
I attached image of my task.
P.s It only needs to draw something similar to it.It can be fixed size.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Reverse polygon
« Reply #6 on: December 16, 2014, 01:27:24 PM »
Something like this ?

ChrisCarlson

  • Guest
Re: Reverse polygon
« Reply #7 on: December 16, 2014, 01:41:02 PM »
You are in class to learn, something something plagiarism?

walesas

  • Guest
Re: Reverse polygon
« Reply #8 on: December 16, 2014, 02:17:52 PM »
Something like this ?
Yes,it`s exactly like this.
You are in class to learn, something something plagiarism?
I`m studying software engineering and we have one course in computer graphics(only autocad).Maybe it`s not good to say that,but teacher is really dumb,we need to learn almost everything at home.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Reverse polygon
« Reply #9 on: December 16, 2014, 02:30:51 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun c:Mouse nil
  2.   ;;    Tharwat 16.12.2014      ;;
  3.   (foreach x '(((0 . "LINE")
  4.                 (8 . "0")
  5.                 (10 0.4 1.63645 0.0)
  6.                 (11 0.25 1.63645 0.0)
  7.                )
  8.                ((0 . "LINE")
  9.                 (8 . "0")
  10.                 (10 0.4 1.38645 0.0)
  11.                 (11 0.4 1.88645 0.0)
  12.                )
  13.                ((0 . "LINE")
  14.                 (8 . "0")
  15.                 (10 0.25 1.43645 0.0)
  16.                 (11 0.25 1.83645 0.0)
  17.                )
  18.                ((0 . "LINE")
  19.                 (8 . "0")
  20.                 (10 0.75 1.38645 0.0)
  21.                 (11 0.3 1.38645 0.0)
  22.                )
  23.                ((0 . "LINE")
  24.                 (8 . "0")
  25.                 (10 0.3 1.88645 0.0)
  26.                 (11 0.75 1.88645 0.0)
  27.                )
  28.                ((0 . "ARC")
  29.                 (8 . "0")
  30.                 (10 0.3 1.43645 0.0)
  31.                 (40 . 0.05)
  32.                 (50 . 3.14159)
  33.                 (51 . 4.71239)
  34.                )
  35.                ((0 . "ARC")
  36.                 (8 . "0")
  37.                 (10 0.3 1.83645 0.0)
  38.                 (40 . 0.05)
  39.                 (50 . 1.5708)
  40.                 (51 . 3.14159)
  41.                )
  42.                ((0 . "ARC")
  43.                 (8 . "0")
  44.                 (10 0.75 1.63645 0.0)
  45.                 (40 . 0.25)
  46.                 (50 . 4.71239)
  47.                 (51 . 1.5708)
  48.                )
  49.                ((0 . "LWPOLYLINE")
  50.                 (100 . "AcDbEntity")
  51.                 (8 . "0")
  52.                 (100 . "AcDbPolyline")
  53.                 (90 . 4)
  54.                 (70 . 0)
  55.                 (43 . 0.02)
  56.                 (38 . 0.0)
  57.                 (39 . 0.0)
  58.                 (10 0.25 1.63645)
  59.                 (40 . 0.02)
  60.                 (41 . 0.02)
  61.                 (42 . 0.0)
  62.                 (10 0.0 1.63645)
  63.                 (40 . 0.02)
  64.                 (41 . 0.02)
  65.                 (42 . 1.0)
  66.                 (10 0.0 0.826939)
  67.                 (40 . 0.02)
  68.                 (41 . 0.02)
  69.                 (42 . -1.0)
  70.                 (10 0.0 0.0)
  71.                 (40 . 0.02)
  72.                 (41 . 0.02)
  73.                 (42 . -0.274223)
  74.                )
  75.               )
  76.     (entmake x)
  77.   )
  78.   (princ)
  79. )
  80.  

walesas

  • Guest
Re: Reverse polygon
« Reply #10 on: December 16, 2014, 02:48:13 PM »
Thank you very much for your answer and time,you really really helped me.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Reverse polygon
« Reply #11 on: December 16, 2014, 02:58:19 PM »
Thank you very much for your answer and time,you really really helped me.

You are welcome  :-)

Hope you donate to the Swamp  ( this website ) to keep this community alive .

walesas

  • Guest
Re: Reverse polygon
« Reply #12 on: December 16, 2014, 04:08:20 PM »
Maybe tommorow I will donate,how can I do that?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Reverse polygon
« Reply #13 on: December 16, 2014, 05:05:56 PM »
Follow the link below.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.