Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: modified "Polygon" command

  1. #1
    Member
    Join Date
    2007-10
    Location
    Arlington, TX
    Posts
    20
    Login to Give a bone
    0

    Default modified "Polygon" command

    I am trying to come up with a modified "polygon" command.
    What I need:
    -always 12 sided
    -always circumscribed about circle
    -enter diameter instead of radius (std is to enter radius)

    I am fairly new to lisps, and thanks for your help in advance.

    This is what i have so far:

    (defun cg12 () ;
    (SETQ pgpt1 (getpoint "\Specify center of polygon: "))
    (command "polygon" "12" pgpt1 "c")
    (princ)
    )

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,830
    Login to Give a bone
    0

    Default Re: modified "Polygon" command

    Here is one way...

    Code:
    
    
    (defun c:g12 () 
      (vl-cmdf
        "._Polygon"
        "12"
        (getpoint "\Specify center of polygon: ")
        "_C"
        (* (getreal "\nEnter diameter: ") 0.5)
      )
    (princ)
    )
    
    
    R.K. McSwain | CAD Panacea |

  3. #3
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: modified "Polygon" command

    Here is another way and with the same result .

    Code:
    (defun c:g12 (/ dia cen)
      (if (and (setq dia (/ (getreal "\nDiameter of Polygon :") 2.0))
    	   (setq cen (getpoint "\nCenter of Polygon :"))
    	)
      (vl-cmdf "_.polygon" 12 cen "_c" dia))
      (princ)
      )
    Tharwat
    Last edited by tharwat; 2010-09-22 at 06:41 AM. Reason: Replacing Rad to Dia.

  4. #4
    Member
    Join Date
    2007-10
    Location
    Arlington, TX
    Posts
    20
    Login to Give a bone
    0

    Default Re: modified "Polygon" command

    Thanks. Both of them worked, its always good to see different ways of coming up with the same result. I appreciate the help.

  5. #5
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: modified "Polygon" command

    Quote Originally Posted by tharwat313 View Post
    Here is another way and with the same result .

    Code:
    (defun c:g12 (/ dia cen)
      (if (and (setq dia (/ (getreal "\nDiameter of Polygon :") 2.0))
           (setq cen (getpoint "\nCenter of Polygon :"))
        )
      (vl-cmdf "_.polygon" 12 cen "_c" dia))
      (princ)
      )
    Tharwat
    Remove possible errors...
    Code:
    (defun c:g12 (/ p d)
      (if (and (setq p (getpoint "\nSpecify center of polygon: "))
               (not (initget 6))
               (setq d (getdist "\nSpecify diameter of polygon: "))
          )
        (command "_.polygon" 12 "_non" p "_c" (/ d 2.))
      )
      (princ)
    )

  6. #6
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: modified "Polygon" command

    Quote Originally Posted by alanjt View Post
    Remove possible errors...
    Code:
    (defun c:g12 (/ p d)
      (if (and (setq p (getpoint "\nSpecify center of polygon: "))
               (not (initget 6))
               (setq d (getdist "\nSpecify diameter of polygon: "))
          )
        (command "_.polygon" 12 "_non" p "_c" (/ d 2.))
      )
      (princ)
    )
    ِAbsolutely right.

    With my codes if user hit <enter> I mean without a value, it would give the following error.

    Code:
    ; error: bad argument type: numberp: nil
    But with your codes, it would exit calmly.

    Thank you so much Alanjt.

    Greatly appreciated.

    Tharwat

  7. #7
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: modified "Polygon" command

    Mr. Alanjt.

    Would you please give us an example of making this small routine the same way that we insert a block with the command insert ?

    For example:

    First enter the dia.
    Second insert the polygon the same way you insert a block.

    I would like to get that kind of technique from you.

    Thanks.

    Tharwat

  8. #8
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: modified "Polygon" command

    Quote Originally Posted by tharwat313 View Post
    Mr. Alanjt.

    Would you please give us an example of making this small routine the same way that we insert a block with the command insert ?

    For example:

    First enter the dia.
    Second insert the polygon the same way you insert a block.

    I would like to get that kind of technique from you.

    Thanks.

    Tharwat
    Just reverse your prompts...

    Code:
    (defun c:g12 (/ d p)
      (initget 6)
      (if (and (setq d (getdist "\nSpecify diameter of polygon: "))
               (setq p (getpoint "\nSpecify center of polygon: "))
          )
        (command "_.polygon" 12 "_non" p "_c" (/ d 2.))
      )
      (princ)
    )

  9. #9
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: modified "Polygon" command

    Thanks.

    But that wasn't what I meant. something like using the function grread or so.

  10. #10
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: modified "Polygon" command

    Quote Originally Posted by tharwat313 View Post
    Thanks.

    But that wasn't what I meant. something like using the function grread or so.
    I don't understand. You've specified the insertion point, size and number of segments. There's nothing else one could do. Are you wanting to use grread to place and/or set size of polygon?

Page 1 of 2 12 LastLast

Similar Threads

  1. 2016: Why Autocad has "None" option in "UNDO" command?
    By MTGH9UU in forum AutoCAD General
    Replies: 3
    Last Post: 2015-09-14, 03:27 PM
  2. Replies: 8
    Last Post: 2012-08-18, 01:31 AM
  3. HOW switch COMMAND "BLOCK" THE "Scale Uniformly"
    By viz_ken1030 in forum AutoLISP
    Replies: 3
    Last Post: 2006-11-17, 12:41 PM
  4. "Modified Linked File"?
    By dbaldacchino in forum Revit Architecture - General
    Replies: 0
    Last Post: 2006-06-21, 06:06 PM
  5. Replies: 3
    Last Post: 2006-03-23, 10:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •