Jump to content

Is there a Lisp like MEASURE and DIVIDE?...


Recommended Posts

Posted (edited)

Is there a lisp like MEASURE and DIVIDE where you can align blocks to the polyline? Kind of like executing the MEASURE or DIVIDE command and forgeting to apply "YES" when it prompts to "Align block with object?"

 

The reason is that we are using a third party software, LandF/X, and its blocks hold some kind of smart data. simply inserting them as a BLOCK will not access the blocks data. Even the COPY command gets things screwy. So what I do is draw a pline along where i need my irrigation head to border a permiter. Then I DIVIDE or MEASURE the line according to the irrigation heads spray radius, then place the heads down along the nodes. Then I rotate them to align them to the center point of a curve or along the pline itself.

 

Seem pretty easy for just a few blocks, but doing this over +10000 individual blocks for a large site will drive you nuts.

 

Thanks

Edited by kili
Posted

Search here for "pline chainages" this is used to write the running chainage along a pline at a given spacing its probabbly a good starting point, change the add text to add block pretty sure later versions autorotate the text.

 

Theres at least two versions here.

Posted

@alanjt: the sequence is very close, except is that im not copying but simply rotating to align, the blocks are already in place but need a lisp to align each block to the pline.

 

my sequence is that i would draw PLINE, then MEASURE according to the irrigatino head spray radius, then insert per LAND F/X their blocks at each node, 0 rotation. then I'd have to go back at each one to rotate along the pline.

 

the catch is that i cannot copy or use the block option in measure and divide because of the data each block. each block has data to do it's sizing and psi calcs. simply copying the object removes the data.

Posted

I wrote a rotation one, but forgot to post. I'll post when I get in the office, in the morning.

Posted
(defun c:RAC (/ ss ent)
 ;; Rotate blocks Along Curve
 ;; Required subroutines: AT:GetSel, AT:AngleAtPoint
 ;; Alan J. Thompson, 12.20.10

 (vl-load-com)

 (if (and (setq ss (ssget "_:L" '((0 . "INSERT"))))
          (setq ent
                 (car
                   (AT:GetSel
                     entsel
                     "\nSelect curve to rotate objects along: "
                     (lambda (x)
                       (not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getEndParam (list (car x))))
                       )
                     )
                   )
                 )
          )
     )
   (progn
     (vlax-for x (setq ss (vla-get-activeselectionset
                            (cond (*AcadDoc*)
                                  ((setq *AcadDoc* (vla-get-activedocument
                                                     (vlax-get-acad-object)
                                                   )
                                   )
                                  )
                            )
                          )
                 )
       (vl-catch-all-apply
         (function
           (lambda (/)
             (vla-put-rotation
               x
               (AT:AngleAtPoint
                 ent
                 (vlax-curve-getClosestPointToProjection ent (vlax-get x 'InsertionPoint) '(0 0 1))
               )
             )
           )
         )
       )
     )
     (vla-delete ss)
   )
 )
 (princ)
)


(defun AT:GetSel (meth msg fnc / ent good)
 ;; meth - selection method (entsel, nentsel, nentselp)
 ;; msg - message to display (nil for default)
 ;; fnc - optional function to apply to selected object
 ;; Ex: (AT:GetSel entsel "\nSelect arc: " (lambda (x) (eq (cdr (assoc 0 (entget (car x)))) "ARC")))
 ;; Alan J. Thompson, 05.25.10
 (setvar 'errno 0)
 (while (not good)
   (setq ent (meth (cond (msg)
                         ("\nSelect object: ")
                   )
             )
   )
   (cond
     ((vl-consp ent)
      (setq good (cond ((or (not fnc) (fnc ent)) ent)
                       ((prompt "\nInvalid object!"))
                 )
      )
     )
     ((eq (type ent) 'STR) (setq good ent))
     ((setq good (eq 52 (getvar 'errno))) nil)
     ((eq 7 (getvar 'errno)) (setq good (prompt "\nMissed, try again.")))
   )
 )
)


(defun AT:AngleAtPoint (e p)
 ;; Return angle along curve, at specified point (on curve)
 ;; e - valid curve (ENAME or VLA-OBJECT)
 ;; p - point on curve
 ;; Alan J. Thompson, 11.04.10
 (angle '(0. 0. 0.) (vlax-curve-getFirstDeriv e (vlax-curve-getParamAtPoint e p)))
)

Posted (edited)

I will try both and see what happens. stay tuned. cheers.

 

update:

both work really well! RAC and Object align.

 

For RAC, i noticed that no matter what angle the object is, it aligns the object perpendicular to the pline. is it how my direction control is setup?, it's always default to east.

Edited by kili

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