Jump to content

how to write a program to get the lines like in the attachment


aswini

Recommended Posts

For fun:

 

(defun c:FOO ( / *error* _GetAngle _Nomutt )
 (vl-load-com)

 (defun *error*  (msg)
   (and oldNomutt (setvar 'nomutt oldNomutt))
   (and oldOsmode (setvar 'osmode oldOsmode))
   (if acDoc
     (vla-endundomark acDoc))
   (cond ((not msg))                                                   ; Normal exit
         ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
         ((princ (strcat "\n** Error: " msg " ** "))))                 ; Fatal error, display it
   (princ))

 (defun _GetAngle  ( basePoint / opt )
   (initget 128 "Point")
   (if (or (setq opt
                  (getkword "\nEnter an angle in degrees [Point] <Point>: "))
           (setq opt "Point"))
     (cond ((= "Point" opt)
            (if (and (not (initget 32))
                     (setq anchorPoint
                            (getpoint basePoint
                                      "\nSpecify angle by point: ")))
              (* 180.0 (/ (angle basePoint anchorPoint) pi))))
           ((atof opt)))))

 (defun _Nomutt  ( on / )
   (if on
     (setvar 'nomutt 0)
     (setvar 'nomutt 1)))

 ((lambda ( acDoc oldNomutt oldOsmode / ss basePoint ang )
    (if (and (setvar 'osmode 5)
             (princ "\nSelect object(s): ")
             (_Nomutt nil)
             (setq ss (ssget "_:L"))
             (_Nomutt T)
             (setq basePoint (getpoint "\nSpecify base point: "))
             (setq ang (_GetAngle basePoint)))
      (progn
        (_Nomutt nil)
        (vla-startundomark acDoc)
        (terpri)
        (initcommandversion 1)
        (vl-cmdf "._array" ss "" "C" basePoint ang "-360" "Y")
        (*error* nil))
      (cond (basePoint (*error* "No angle specified"))
            (ss (*error* "No base point specified"))
            ((*error* nil)))))
   (vla-get-activedocument (vlax-get-acad-object))
   (getvar 'nomutt)
   (getvar 'osmode)))

Link to comment
Share on other sites

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • aswini

    7

  • BIGAL

    4

  • BlackBox

    3

  • pBe

    3

Top Posters In This Topic

It is working excellent thanq verymuch,i have onemore doubt if i want the input as only number of lines and not the angle,what i have to do??

Thanks

 

You are welcome aswini:

 

(defun c:FunArray  (/ ss bp op)
(setq val (mapcar '(lambda (v)
                        (getvar v)) (list 'Cmdecho 'Osmode)))
(cond ((and
     (princ "\mSelect Objects to array: ")      
     (setq ss (ssget))
     (setvar 'osmode 5)(setvar 'cmdecho 0)
     (setq bp (getpoint "\nPick Base point:"))
     (setq ang (cond
    ((getangle (strcat "\nEnter Angle <" (angtos (setq ang
      (cond ( ang ) ( 0.0 ))))">: "
        )))( ang ))
     ))
     (initcommandversion 1)
     (command "_array" ss "" "C"  bp (/ (* ang 180.0) pi)(progn
           (setq op (getint "\nNumber of Items: [Enter for 360 fill]: "))
           (if op op  "-360"))  "Y")
      ))
     (mapcar '(lambda (v y)
                        (setvar v y)) (list 'Cmdecho 'Osmode) val)
     (princ)
     )

 

@pBe , You are changing the OP osmode settings without re-set them back with (setvar 'osmode 5)

 

I'm lazy that way tharwat. :lol:

 

For fun:

 

Its giving odd results when using "point" option. me thinks :)

Link to comment
Share on other sites

Its giving odd results when using "point" option. me thinks :)

 

Hrmmm... That must be due to my only testing the routine in WCS, with Plan=World. I also neglected to TRANSlate the point(s). o:)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...