Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Code to turn blocks quickly when imported

Hi,

when I import a blocks (e.g. valve). I need to do a couple of clicks to turn it in the right directions.

However, it would be great that after import you can hit a key to turn the block in a certain direction. After a couple of clicks of this key you will have your block in the correct position.

Is there anybody how knows if this is possible with a piece of short code?

Comments

  • It would be easy to create such a command, but tell us more about exactly what you want it to do.

    If you want a command that rotates the selection set 90° about its centroid each time you press a key, I already have that. And one that flips the selection set horizontally or vertically about its centroid with just a single click to specify whether horizontal or vertical.

  • The DUCS can take care of this.

  • There is solutions like press up arrow and it rotates a fixed angle or press any key Enter to exit or this is my effort.

    (if (not AH:Butts)(load "Multi Radio buttons.lsp"))
    (if (not but)(setq but 1))
    (setq ans (ah:butts but "V" '("Choose angle " " 0" " 22.5 " 45" " 67.5" " 90" " 112.5" " 135" " 157.5 " " 180")) )

    image.png
    188 x 462 - 7K
    lsp
    lsp
    Multi radio buttons.lsp
    3K
  • @Anthony Apostolaros said:
    It would be easy to create such a command, but tell us more about exactly what you want it to do.

    If you want a command that rotates the selection set 90° about its centroid each time you press a key, I already have that. And one that flips the selection set horizontally or vertically about its centroid with just a single click to specify whether horizontal or vertical.

    after you insert a block I would for example hit the arrows and the block turns in a certain direction. If it works already with 90 degrees, I would really appreciate it! Do you have such code?

  • @ALANH said:
    There is solutions like press up arrow and it rotates a fixed angle or press any key Enter to exit or this is my effort.

    (if (not AH:Butts)(load "Multi Radio buttons.lsp"))
    (if (not but)(setq but 1))
    (setq ans (ah:butts but "V" '("Choose angle " " 0" " 22.5 " 45" " 67.5" " 90" " 112.5" " 135" " 157.5 " " 180")) )

    does this mean you can turn the block at inserting in the right direction?

  • edited June 15

    @Bas Weinans said:
    after you insert a block I would for example hit the arrows and the block turns in a certain direction. If it works already with 90 degrees, I would really appreciate it! Do you have such code?

    Bas, I'm still not clear on what you want the custom command to do, but you're welcome to this if it helps. It rotates the selection set 90° about its centroid. It leaves the selection set still selected, so you can just keep pressing Space (or the function key I've assigned it to) to spin the selection set around to the desired orientation. That feature might be a problem if you work with PickAdd = On, but you can get rid of it by deleting the 5th line (with sssetfirst) or putting a semi-colon in front of it. You can change the angle of rotation from 90.0 to whatever you want, in the 4th line.

    (defun c:r90 ()
    (setq ss1 (ssget))
    (setq p1 (trans (apply 'acet-geom-mid-point (vle-getboundingbox ss1)) 0 1) )
    (command "Rotate" ss1 "" p1 90.0)
    (sssetfirst nil (ssget "P"))
    )

    I also have this custom version of the Rotate command, which eliminates the other options and only accepts a fulcrum point plus either the From and To points of the sweep or else the sweep angle in degrees.
    (defun c:Rot (/ ss1 p1 p2 n1)
    (setq ss1 (ssget) )
    (setq p1 (getpoint "\nVertex of rotation angle: "))
    (initget 128)
    (setq p2 (getpoint p1 "\nPick start point of angle or Enter angle as a number: "))
    (if (= 'str (type p2)) (progn (setq n1 (atof p2)) (command "Rotate" ss1 "" p1 n1))
      (progn (command "Rotate" ss1 "" p1 "B" p1 p2)
      (while (> (getvar "cmdactive") 0) (command pause)))    )
    (sssetfirst nil (ssget "P"))
    )

    If you want to insert a block and rotate it around the insertion point, the built-in -Insert command does that, in 90° increments if Ortho is on or if you hold down the Shift key.
Sign In or Register to comment.
Origami
Origami is the Japanese word for paper folding. ORI means to fold and KAMI means paper and involves the creation of paper forms usually entirely by folding.

Powered by VanillaForums, Designed by Steam