Jump to content

Recommended Posts

Posted

hi

 

i want to create a rectangle, lets say 40x40, and dublicat it 100 times by 20 units inteval, than mirror all the 100 instance verticaly , than move all 200 entities 200 units down

 

(you an think of whatever basic action you want, i just want to see this code and trace its sources in the help reference so i can understand how to use the help)

 

please help

 

(defun dm()

(vl-load-com)
(setq acadObject   (vlax-get-acad-object))
(setq acadDocument (vla-get-ActiveDocument acadObject))
(setq mSpace       (vla-get-ModelSpace acadDocument))




(setq mycircle    (vla-addCircle mSpace 
(vlax-3d-point '(3.0 3.0 0.0)) 2.0))

 (setq cop2 (vla-copy mycircle))

 (setq util (vla-get-utility 
                  (vla-get-activedocument 
                       (vlax-get-acad-object))))

 ;move the object
(vla-move mycircle BP PT2)

 
 

 )

 

Thanks

Shay

Posted

Rectang or circle like code a 100 times use "entlast" then "Array" dont copy thats what Array does. If you draw on 1 layer particuarly a temporary one then you can do "boundingbox" search here, and then say "mirror" change final resulting objects (boundingbox) to correct layer this way your temp layer has nothing on it.

 

Not sure on the vla-addarray else (command "_Array" follow prompts)

Posted

Well the OP asked for the VL way of doing it:

(vl-load-com)
(setq *Application*    (vlax-get-acad-object)
     *ActiveDocument* (vla-get-ActiveDocument *Application*))

;; Draw a rectangle
(defun ax_DrawRect  (pt1 pt2 / Space obj)
 (setq Space (vlax-get *ActiveDocument*
                       (if (< (getvar "CVport") 2) ;Check which space is active
                         'PaperSpace
                         'ModelSpace))
       pt1   (mapcar '+ pt1 '(0. 0.)) ;Ensure only 2D points
       pt2   (mapcar '+ pt2 '(0. 0.)) ;dito
       ;; Create the rectangle
       obj   (vlax-invoke
               Space
               'AddLightWeightPolyline
               (append pt1 (list (car pt2) (cadr pt1)) pt2 (list (car pt1) (cadr pt2)))))
 (vla-put-Closed obj :vlax-true)
 obj)

;; Copy an object
(defun ax_Copy  (obj vector / new)
 (if (not (vl-catch-all-error-p (setq new (vl-catch-all-apply 'vla-Copy (list obj)))))
   (progn (vlax-invoke new 'Move '(0. 0. 0.) vector) new)))

;; Mirror an object
(defun ax_Mirror (obj pt1 pt2 / new)
 (if (not (vl-catch-all-error-p (setq new (vl-catch-all-apply 'vla-Mirror (list obj (vlax-3d-point pt1) (vlax-3d-point pt2))))))
   new))

And then to use those functions:

_$ (setq obj (ax_DrawRect '(0. 0.) '(40. 40.)))
#<VLA-OBJECT IAcadLWPolyline 000000002fc03dd8>
_$ (setq obj1 (ax_Copy obj '(60. 0. 0.)))
#<VLA-OBJECT IAcadLWPolyline 000000002fc04258>
_$ (setq obj2 (ax_Mirror obj '(0. 0. 0.) '(60. 0. 0.)))
#<VLA-OBJECT IAcadLWPolyline 000000002fc02c98>

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...