Jump to content

Lisp-Command: Slice normal (rectangular) to X,Y,Z-axis


Randolph

Recommended Posts

Thank you for beeing part of this forum.

 

This is my problem:

 

I very often use the SLICE command to cut solids. This is my simple shortcut:

 

(DEFUN C:S ()(COMMAND "_SLICE"))

 

As in most cases I cut parallel to the UCS planes, I almost always have to type one of the following options:

 

[...XY/YZ/ZX...] xy 

 

With hundreds of cuts per day, this becomes tiresome.

 

And this is my question:

 

To speed up modelling, it would be very helpful to have 3 shortcut commands:

 

SX ... slice parallel to YZ-plane

SY ... slice parallel to ZX-plane

SZ ... slice parallel to XY-plane

 

Procedure: sx RightMouseButton select Object(s) RMB select point on plane RMB select point on side to keep RMB

 

Can anybody post a LISP-Code? Your help will be very appreciated. Thank you!

 

Randolph

Link to comment
Share on other sites

I already got it:

 

 
(DEFUN C:SX ()
(SETQ OBJEKTE (SSGET))
(SETQ PUNKT (GETPOINT "\nPoint on YZ plane:"))
(SETQ SEITE (GETPOINT "\nSide to keep:"))
(COMMAND "_OSNAP" "")
 (COMMAND "_SLICE" "_SI" OBJEKTE "_YZ" PUNKT SEITE)
(COMMAND "_OSNAP" "_END,_INT,_MID,_CEN,_INS,_PER")
(COMMAND "_REDRAW")
(SETQ OBJEKTE NIL)
)

Link to comment
Share on other sites

Hi

 

Here's a "3 in 1"

 

(mapcar
 '(lambda (fun opt)
    (eval (list 'defun
                fun
                nil
                (list 'vl-cmdf "_.slice" '(ssget) "" opt pause pause)
                '(princ)
          )
    )
  )
 '(c:SX c:SY c:SZ)
 '("XY" "YZ" "ZX")
)

Link to comment
Share on other sites

keeps both sides. Maybe somebody needs it, though I guess it's much too simple to interest many of you :unsure:

 

 
(DEFUN C:SXA ()
(SETQ OBJEKTE (SSGET))
(SETQ PUNKT (GETPOINT "\nPunkt :"))
(COMMAND "_OSNAP" "")
(COMMAND "_SLICE" "_SI" OBJEKTE "_YZ" PUNKT "_B")
(COMMAND "_OSNAP" "_END,_INT,_MID,_CEN,_INS,_PER")
(COMMAND "_REDRAW")
(SETQ OBJEKTE NIL)
)

Link to comment
Share on other sites

The mapcar statement is just a funny elegant way to avoid making similar functions which differ only for some options.

 

You can write 3 (or 6) (defun ...) it will do the same but have a look at the vl-cmdf function instead of command, it allows to use (ssget) as argument.

 

(defun c:SX ()
 (vl-cmdf "_.slice" (ssget) "" "XY" pause pause)
 (princ)
)

 

To go further, a "6 in 1"

 

(mapcar
 '(lambda (fun opt1 opt2)
    (eval (list 'defun
                fun
                nil
                (list 'vl-cmdf "_.slice" '(ssget) "" opt1 pause opt2)
                '(princ)
          )
    )
  )
 '(c:SX c:SY c:SZ c:SXA c:SYA c:SZA)
 '("XY" "YZ" "ZX" "XY" "YZ" "ZX")
 '(pause pause pause "_both" "_both" "_both")
)

Link to comment
Share on other sites

Hey, that looks familiar. I must have seen you do this elsewhere.

(mapcar
 '(lambda (f r)
    (eval (list 'defun
        f
        nil
        (list 'setvar "filletrad" r)
        (list 'princ (strcat "\nFillet radius set to: " (rtos r)))
        (list 'vl-cmdf "_.fillet")
        '(princ)
      )
    )
  )
 '(c:FF    c:F1    c:F15    c:F2    c:F3    c:F4    c:F5    c:F6    c:F7    c:F8    c:F9)
 '(0        1    1.5    2    3    4    5    6    7    8    9)
)

Link to comment
Share on other sites

Hi alan,

 

This is not mine (I don't use so much fillet) but I wrote one some times ago to change between predefined views with the numpad.

 

(mapcar
 '(lambda (f v)
    (eval (list 'defun
                f
                nil
                (list 'command "_.view" v)
                '(princ)
          )
    )
  )
 '(c:0 c:1 c:2 c:3 c:4 c:5 c:6 c:7 c:8 c:9)
 '("_bottom" "_swiso" "_front" "_seiso" "_left" "_top" "_right" "_nwiso"
   "_back" "_neiso")
)

Link to comment
Share on other sites

Hi alan,

 

This is not mine (I don't use so much fillet) but I wrote one some times ago to change between predefined views with the numpad.

 

(mapcar
 '(lambda (f v)
    (eval (list 'defun
                f
                nil
                (list 'command "_.view" v)
                '(princ)
          )
    )
  )
 '(c:0 c:1 c:2 c:3 c:4 c:5 c:6 c:7 c:8 c:9)
 '("_bottom" "_swiso" "_front" "_seiso" "_left" "_top" "_right" "_nwiso"
   "_back" "_neiso")
)

 

 

Oh, I wasn't implying you wrote it. I was saying I must have modeled it after you. That looks familiar, so I probably saw that one posted once.

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