Jump to content

Recommended Posts

Posted

Hi

 

 

I'm trying to come of with a piece of code which will have the ability to fillet with a given radius regardless if it is a polyline of line. I got this routine working for Rebar bending but it only works on lines. I want to make it "POLYLINE friendly" as well.

 

 

Here is a piece of code. I get stuck in the part where it decides t is either LINE or POLYLINE. Any help or lead to similar codes is appriciated.

 

 



; example for a fixed r=40 handling


(defun c:fg16 (/ CMDECHO CMDDIA FRAD E1 E2)
   (princ "\fillet diam. 16, r = 40 ")
   (setq ERR     *ERROR*
         *ERROR* LISP-ERR
         CMDECHO 0
         CMDDIA  0
         E1      NIL
         E2      NIL
         FRAD    (getvar "filletrad")
   ) ;_ end of setq
   (setvar "filletrad" 40)
   (setq E1 (entsel "\nSelect first object: "))
   (while (/= E1 nil)
       (progn (setq tipoent (cdr (assoc 0 (entget (car (E1))))))  ; hmmm..
                                                           
              (if (= tipoent "POLYLINE")                                    ; if it is ONE polyline , handle it
                  (command "_.fillet" "_polyline" "radius" "40" E1)
                                                                                       ; end for polyline, but it fails (?)
                  (progn (redraw (car E1) 3)                               ; start part for single LINES
                         (setq E2 (entsel "\tsecond: "))                   ; second line needed
                         (redraw (car E2) 3)
                         (command "fillet" E1 E2)
                         (setq E1 (entsel "\nfirst: "))
                  )                              ; end part for single
              )
       )
   )
   (setvar "filletrad" FRAD)
   (princ)
)


for fixed radius polyline as well.JPG

Posted

Try:

 

(lambda ( / cmd e typ )
 (setq cmd (cond (command-s)(vl-cmdf)(command))) (setvar 'errno 0)
 (while (zerop (getvar 'errno)) (setq e (car (entsel "\nSelect object to fillet <exit>: ")))
   (cond
     ( (or (not e) (= 7 (getvar 'errno))) (setvar 'errno 0) )
     ( (wcmatch (setq typ (cdr (assoc 0 (entget e)))) "*POLYLINE")
       (cmd "_.fillet" "_polyline" "radius" (vl-prin1-to-string (getvar 'filletrad)) e)
     )
     ( (= typ "LINE") (cmd "fillet" e "\\") )
     ( (alert "Invalid object.") )
   )
 )
)

Posted

Just a small remark:

For predictable results it is better to supply the _Fillet command with the complete entsel list instead of just the ename.

(setq lst (entsel))
(command "_.fillet" lst "\\")

Posted

@Grrr:

Looking at the docs I see that pause is not allowed for command-s. Your code suggests that "\\" (the equivalent of pause) is. This seems strange. Have you tested this?

Posted
Just a small remark:

For predictable results it is better to supply the _Fillet command with the complete entsel list instead of just the ename.

(setq lst (entsel))
(command "_.fillet" lst "\\")

 

I was not aware that you could supply the entsel list, thanks!

 

@Grrr:

Looking at the docs I see that pause is not allowed for command-s. Your code suggests that "\\" (the equivalent of pause) is. This seems strange. Have you tested this?

 

Yup, I've tested my fragment on ACAD2017 - works fine, just like in Hans's demo.

Posted

@halam:

What if the user wants to fillet two polylines? The current code does not allow for that.

Posted

Maybe this:

(vl-load-com)

(defun c:AltFillet ( / *error* N_Radius N_Select doc entselA entselB)

 (defun *error* (msg)
   (setvar 'cmdecho 1)
   (vla-endundomark doc)
 )

 (defun N_Radius ( / new)
   (if (setq new (getdist (strcat "\nFillet radius <" (rtos (getvar 'filletrad)) ">: ")))
     (setvar 'filletrad new)
   )
 )

 (defun N_Select (msg / inp)
   (setq inp T)
   (while (and inp (not (vl-consp inp)))
     (initget 128 "Radius")
     (setq inp
       (entsel
         (strcat
           "\nFillet (radius=" (rtos (getvar 'filletrad)) "):  Radius/<" msg ">: "
         )
       )
     )
     (if (= "Radius" inp)
       (N_Radius)
     )
   )
   inp
 )

 (setq doc (vla-get-activedocument (vlax-get-acad-object)))
 (vla-endundomark doc)
 (vla-startundomark doc)
 (setvar 'cmdecho 0)
 (cond
   ((not (setq entselA (N_Select "Select first entity")))
     nil
   )
   ((vl-position (vla-get-objectname (vlax-ename->vla-object (car entselA))) '("AcDb2dPolyline" "AcDbPolyline"))
     (if (setq entselB (N_Select "Select second entity or Enter to fillet selected polyline"))
       (command "_.fillet" entselA entselB)
       (command "_.fillet" "_polyline" entselA)
     )
   )
   ((setq entselB (N_Select "Select second entity"))
     (command "_.fillet" entselA entselB)
   )
 )
 (setvar 'cmdecho 1)
 (vla-endundomark doc)
 (princ)
)

Posted
@halam:

What if the user wants to fillet two polylines? The current code does not allow for that.

 

Because it was meant for 2d rebar detailling it is not likely, either the user starts rebar doing one polyline or multiple single lines. However any improvement is welcome to make a general versitile fillet routine. Which makes me wonder if 3d polylines can be handled accordingly.. (for 3d rebar)

Posted
Which makes me wonder if 3d polylines can be handled accordingly.. (for 3d rebar)
Last time I checked 3D polylines could not be filleted. But you probably know that as well...
Posted (edited)
Last time I checked 3D polylines could not be filleted. But you probably know that as well...

Off course i was not aware, just a dumb AutoCAD user having silly ideas. I must be me missing some deep mathematical reason here ;-) thanks for replying also Marko!

 

 

Edit:

3Dpolyline could in theory be used for 3D rebar array.

attached as a theoretical idea ..

..calculate and add the two points before and after bending, ..add bending parameter.., quadratic bending,..etc. make it 3D.., array..

but i think its all way to complcated to do it with lisp. Workflow for me to work 3d rebar is to just UCS right first and work with 2Dpolylines and work from there.

3dpolyline fillet for rebar.jpg

Edited by halam

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