Jump to content
zwonko

LISP move block (vertical or horizontal) to selected polyline

Recommended Posts

zwonko

I'm looking for LISP which will help me to move blocks to intersect selected polyline. The problem is:

-I have group of blocks in some  spacing horizontally or vertically

-I have polyline above or below, left or right from this blocks. The polyline consist of few lines in different angles or arc sometimes

-now I'm moving blocks one by one and moving it to intersect polyline

It is possible to make LISP which will do intersecition? For example I,m selecting group of blocks, after that polyline, after that say: X,Y, (maybe up,down,left,right) and now LISP is moving block to intersect polyline?

If it is possible even to do lisp which will make it only UP it will be great. I can always rotate and move polyline and group of blocks. I have hundreds of blocks to move like this...

 

I've gave attachment what I need.

 

help_me_please.dwg

Share this post


Link to post
Share on other sites
marko_ribar

Here is for UP/DOWN, but I am sure you can figure it also for LEFT/RIGHT...

 

(defun c:moveblksup ( / c ss i b p q )

  (vl-load-com)

  (while
    (or
      (not (setq c (car (entsel "\nPick curve, placed up or down..."))))
      (if c
        (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getstartpoint (list c)))
      )
    )
    (prompt "\nMissed or picked entity not curve...")
  )
  (while
    (or
      (prompt "\nSelect blocks you want to move up/down until intersecting with previously picked curve...")
      (not (setq ss (ssget "_:L" '((0 . "INSERT")))))
    )
    (prompt "\nEmpty sel.set...")
  )
  (repeat (setq i (sslength ss))
    (setq b (ssname ss (setq i (1- i))))
    (setq p (cdr (assoc 10 (entget b))))
    (setq q (vlax-curve-getclosestpointtoprojection c p '(0.0 1.0 0.0)))
    (if q
      (vla-move (vlax-ename->vla-object b) (vlax-3d-point p) (vlax-3d-point q))
    )
  )
  (princ)
)

 

Share this post


Link to post
Share on other sites
Ish

u can use array command. 

Share this post


Link to post
Share on other sites
zwonko
Posted (edited)

Thank You so much @marko_ribar! That exacly what i want to have :)

 

Changed it do left and right :) maybe someone will need it

 

(defun c:moveblklr ( / c ss i b p q )

  (vl-load-com)

  (while
    (or
      (not (setq c (car (entsel "\nPick curve, placed left or right..."))))
      (if c
        (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getstartpoint (list c)))
      )
    )
    (prompt "\nMissed or picked entity not curve...")
  )
  (while
    (or
      (prompt "\nSelect blocks you want to move right/left until intersecting with previously picked curve...")
      (not (setq ss (ssget "_:L" '((0 . "INSERT")))))
    )
    (prompt "\nEmpty sel.set...")
  )
  (repeat (setq i (sslength ss))
    (setq b (ssname ss (setq i (1- i))))
    (setq p (cdr (assoc 10 (entget b))))
    (setq q (vlax-curve-getclosestpointtoprojection c p '(1.0 0.0 0.0)))
    (if q
      (vla-move (vlax-ename->vla-object b) (vlax-3d-point p) (vlax-3d-point q))
    )
  )
  (princ)
)

 

4 hours ago, Ish said:

u can use array command. 

 

First of all I hate arrays. Groups are better to use for me. Second, maybe I'm don't know this option well, but propably i can't get what i want with array. Last one, it is like that i have blocks in some spacing in few views. In one they are visible as in line in second it must be "attached" to polyline, so for me is better to use group and LISP above. I'm sure that the spacing are the same.

Edited by zwonko

Share this post


Link to post
Share on other sites
BIGAL
Posted (edited)

Maybe wrap something like this into the while then run the correct axis option could use initget.

 

image.png.0deb9155992f4edc3b5b7246a2fb8352.png

 


(defun c:moveblk ( / c ss i b p q )
  (vl-load-com)
  (while
    (or
      (not (setq c (car (entsel "\nPick curve"))))
      (if c
        (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getstartpoint (list c)))
      )
    )
    (prompt "\nMissed or picked entity not curve...")
  )
  (while
    (or
      (prompt "\nSelect blocks you want to move  intersecting with previously picked curve...")
      (not (setq ss (ssget "_:L" '((0 . "INSERT")))))
    )
    (prompt "\nEmpty sel.set...")
  )
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (= but nil)(setq but 1))
;(setq ans (ah:butts but "h"  '("Choose" "U-D" "L-R" )))
(setq ans (ah:butts but "v"  '("Choose" "U-D" "L-R" )))
  (repeat (setq i (sslength ss))
    (setq b (ssname ss (setq i (1- i))))
    (setq p (cdr (assoc 10 (entget b))))
    (cond
    ( (= ans "L-R") (setq q (vlax-curve-getclosestpointtoprojection c p '(1.0 0.0 0.0))))
    ( (= ans "U-D") (setq q (vlax-curve-getclosestpointtoprojection c p '(0.0 1.0 0.0))))
    )
     (if q
      (vla-move (vlax-ename->vla-object b) (vlax-3d-point p) (vlax-3d-point q))
    )
  )
  (princ)
)

(c:moveblk)

 

 

Multi radio buttons.lsp

Edited by BIGAL

Share this post


Link to post
Share on other sites
zwonko

That one is very nice :) like I wan't it to be :)

thanks @BIGAL

Share this post


Link to post
Share on other sites
BIGAL

Thanks to Marko for the initial code I just tweaked it a bit.

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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