+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 20
  1. #1
    Junior Member
    Computer Details
    careca's Computer Details
    Operating System:
    Win7 64
    Discipline
    Landscape
    careca's Discipline Details
    Occupation
    Urban Planner
    Discipline
    Landscape
    Using
    AutoCAD 2011
    Join Date
    Aug 2012
    Location
    Tokyo, Japan
    Posts
    13

    Default Help with Lisp doing Multiple Fillets

    Registered forum members do not see this ad.

    Hi all,

    this might be one of my first lisp scripts....and I am kind of stuck.

    What I want to create is an app that automatizes the process of creating a boundary, making an internal offset, fillet the created offset, and finally delete the original boundary. All should work while picking points.

    As I found out that I have to explode the offset element first, to make all segments into polylines for proper filleting (otherwise arcs etc don't work), that's where I got stuck.

    If somebody had any helpful hints for me, this would be highly appreciated.

    thnx.
    careca

    Here's the code of how far I got:

    Code:
     
    (defun c:xfillet (/ pt)
    
        ; while picking point -----------------------------
        (while (setq pt (getpoint "\nPick internal point: "))
    
        (command "_.-boundary" "_a" "_i" "_n" "" "" "_non" pt "")
    
            ; store original boundary object
            (setq original_boundary (entlast))
    
            ; make offset
            (command "_.offset" 10 (entlast) "_non" pt "")
            
            ; explode offset
            (command "_.explode" (entlast))
    
            ; load selection set
            (setq ss (ssget "_P"))
            
            ;counter
            (setq x 1) 
            
            ;loop for all elements -------------------
            (repeat (sslength ss)
                     
                (setq pa (getvar "peditaccept"))
                
                ; convert all segments into polylines -> so fillet works on all elements
                (setvar "peditaccept" 1)
                (command "pedit" ss nil)
                (setvar "peditaccept" pa)
                
                ; copy element onto layer 0
                (command "_.chprop" (entlast) "" "LA" "0" "")
                
                ; change color of element (included just for texting)
                (command "change" (entlast) "" "prop" "color" x "")
    
                ; ++++++++++++++++++++++++++++++++
                ; ++++++++++++++++++++++++++++++++
                
                ; what I want to accomplish
                
                ; store first element
                if x = 1 then
                store element in el1
                
                ; loop though elements, make fillets bit by bit
                if x >= 2
                make fillet with el1
                store new element as el1
                
    
                ; ++++++++++++++++++++++++++++++++
                ; ++++++++++++++++++++++++++++++++
                
                (setvar "peditaccept" pa)
                
                ; counter up
                (setq x (+ x 1))
             
             ; _end repeat
             )
             
             ; delete original boundary
             (command "_.erase" original_boundary "")
    
    
        ) ; end while
        
        ;(princ)
    ) ; end

  2. #2
    Forum Deity Dadgad's Avatar
    Using
    AutoCAD 2012
    Join Date
    Nov 2011
    Location
    At the confluence of worthlessness & invaluability
    Posts
    3,135

    Default

    Hello careca, welcome to the forum.

    If you set your PEDITACCEPT system variable setting to 1, at your commandline, then
    you will be able to fillet the offset entity by using the POLYLINE option in the FILLET commandline prompts.
    I hope that helps you.
    Attached Images
    Volume and repetition do not validate opinions forged in the absence of thought.

  3. #3
    Junior Member
    Computer Details
    careca's Computer Details
    Operating System:
    Win7 64
    Discipline
    Landscape
    careca's Discipline Details
    Occupation
    Urban Planner
    Discipline
    Landscape
    Using
    AutoCAD 2011
    Join Date
    Aug 2012
    Location
    Tokyo, Japan
    Posts
    13

    Default

    Quote Originally Posted by Dadgad View Post
    Hello careca, welcome to the forum.

    If you set your PEDITACCEPT system variable setting to 1, at your commandline, then
    you will be able to fillet the offset entity by using the POLYLINE option in the FILLET commandline prompts.
    I hope that helps you.
    Hi Dadgad,
    thanks for your reply.

    I actually tried this, but it seems not to be working.
    The arc sections will be spared out when trying to do all at once via polyline.

    That's why I thought I loop though the selection set of elements...

    Martin

  4. #4
    Forum Deity Dadgad's Avatar
    Using
    AutoCAD 2012
    Join Date
    Nov 2011
    Location
    At the confluence of worthlessness & invaluability
    Posts
    3,135

    Default

    You could create your arcs using the POLYLINE command.
    Specify the starting point, then A> and any arcs created in this way will be POLYLINES.
    Volume and repetition do not validate opinions forged in the absence of thought.

  5. #5
    Junior Member
    Computer Details
    careca's Computer Details
    Operating System:
    Win7 64
    Discipline
    Landscape
    careca's Discipline Details
    Occupation
    Urban Planner
    Discipline
    Landscape
    Using
    AutoCAD 2011
    Join Date
    Aug 2012
    Location
    Tokyo, Japan
    Posts
    13

    Default

    Quote Originally Posted by Dadgad View Post
    You could create your arcs using the POLYLINE command.
    Specify the starting point, then A> and any arcs created in this way will be POLYLINES.
    ok, in a nutshell, here is what I want to achieve:

    xfillet.jpg

    basically a continuous one-click operation that takes me from step 1 to 6.
    but as it happens, between step 5 and 6, the offset polyline needs to be exploded to handle all fillets, otherwise the edges where (original) arc elements touch do not work.

    careca

  6. #6
    Forum Deity Dadgad's Avatar
    Using
    AutoCAD 2012
    Join Date
    Nov 2011
    Location
    At the confluence of worthlessness & invaluability
    Posts
    3,135

    Default

    I see what you mean, I was quite surprised that when the BOUNDARY command creates a CLOSED POLYLINE,
    which having been OFFSET with the POLYLINE option, and despite having been a closed polyline, still yields the following message ..... another message that keeps coming up about one line having been divergent (polyline arc).
    Attached Images
    Volume and repetition do not validate opinions forged in the absence of thought.

  7. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,743

    Default

    Give this a try:

    Code:
    (defun c:xf ( / *error* cm e0 e1 e2 e3 el p1 pe )
    
        (defun *error* ( msg )
            (if (= 'int (type cm))
                (setvar 'cmdecho cm)
            )
            (if (= 'int (type pe))
                (setvar 'peditaccept pe)
            )
            (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
                (princ (strcat "\nError: " msg))
            )
            (princ)
        )
        
        (setq cm (getvar 'cmdecho)
              pe (getvar 'peditaccept)
        )
        (setvar 'cmdecho 0)
        (setvar 'peditaccept 1)
        (while (setq p1 (getpoint "\nPick Internal Point <Exit>: "))
            (setq e0 (entlast)
                  el nil
            )
            (command "_.-boundary" "_A" "_I" "_N" "" "_O" "_P" "" "_non" p1 "")
            (setq e1 (entlast))
            (if (not (eq e0 e1))
                (progn
                    (command "_.offset" 10.0 e1 "_non" p1 "")
                    (setq e2 (entlast))
                    (if (not (eq e1 e2))
                        (progn
                            (command "_.chprop" e2 "" "_LA" "0" "_C" 1 "")
                            (command "_.explode" e2)
                            (setq e3 e2)
                            (while (setq e3 (entnext e3))
                                (setq el (cons e3 el))
                            )
                            (mapcar
                               '(lambda ( a b ) (setvar 'filletrad 10.0) (command "_.fillet" a b))
                                (cons (last el) el)
                                el
                            )
                            (command "_.pedit" "_M")
                            (while (setq e2 (entnext e2))
                                (command e2)
                            )
                            (command "" "_J" "" "")
                        )
                        (alert "Unable to perform offset.")
                    )
                    (entdel e1)
                )
                (alert "Unable to detect boundary.")
            )
        )
        (setvar 'peditaccept pe)
        (setvar 'cmdecho cm)
        (princ)
    )
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  8. #8
    Senior Member marko_ribar's Avatar
    Computer Details
    marko_ribar's Computer Details
    Operating System:
    Windows 7 Ultimate X64
    Computer:
    Intel quad core CPU 4x2.66GHz, 8GB RAM
    Motherboard:
    INTEL compatibile
    CPU:
    quad core 4x2.66GHz
    RAM:
    8GB
    Graphics:
    NVIDIA GeForce 6600 GT
    Primary Storage:
    250 GB
    Secondary Storage:
    500 GB
    Monitor:
    Samsung 17''
    Discipline
    Architectural
    marko_ribar's Discipline Details
    Occupation
    Architecture, project designer, project visualisation
    Discipline
    Architectural
    Details
    space design - modeling and animations
    Using
    AutoCAD 2012
    Join Date
    Feb 2010
    Location
    Belgrade, Serbia, Europe
    Posts
    338

    Default

    Excellent Lee... Only slight modification to your code (highlighted) :

    Code:
    (defun c:xf ( / *error* cm e0 e1 e2 e3 el p1 pe ) (vl-load-com)
    
        (defun *error* ( msg )
            (if (= 'int (type cm))
                (setvar 'cmdecho cm)
            )
            (if (= 'int (type pe))
                (setvar 'peditaccept pe)
            )
            (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
                (princ (strcat "\nError: " msg))
            )
            (princ)
        )
        
        (setq cm (getvar 'cmdecho)
              pe (getvar 'peditaccept)
        )
        (setvar 'cmdecho 0)
        (setvar 'peditaccept 1)
        (while (setq p1 (getpoint "\nPick Internal Point <Exit>: "))
            (setq e0 (entlast)
                  el nil
            )
            (command "_.-boundary" "_A" "_I" "_N" "" "_O" "_P" "" "_non" p1 "")
            (setq e1 (entlast))
            (if (not (eq e0 e1))
                (progn
                    (command "_.offset" 10.0 e1 "_non" p1 "")
                    (setq e2 (entlast))
                    (if (not (eq e1 e2))
                        (progn
                            (command "_.chprop" e2 "" "_LA" "0" "_C" 1 "")
                            (command "_.explode" e2)
                            (setq e3 e2)
                            (while (setq e3 (entnext e3))
                                (setq el (cons (vlax-curve-getpointatparam e3 (+ (vlax-curve-getstartparam e3) (/ (- (vlax-curve-getendparam e3) (vlax-curve-getstartparam e3)) 2.0))) el))
                            )
                            (mapcar
                               '(lambda ( a b ) (setvar 'filletrad 10.0) (command "_.fillet" a b))
                                (cons (last el) el)
                                el
                            )
                            (command "_.pedit" "_M")
                            (while (setq e2 (entnext e2))
                                (command e2)
                            )
                            (command "" "_J" "" "")
                        )
                        (alert "Unable to perform offset.")
                    )
                    (entdel e1)
                )
                (alert "Unable to detect boundary.")
            )
        )
        (setvar 'peditaccept pe)
        (setvar 'cmdecho cm)
        (princ)
    )
    M.R.

    Marko Ribar, d.i.a. (graduated engineer of architecture)
    M.R. on YouTube

  9. #9
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,743

    Default

    Quote Originally Posted by marko_ribar View Post
    Excellent Lee... Only slight modification to your code (highlighted) :
    Did the original not work for you?
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  10. #10
    Senior Member marko_ribar's Avatar
    Computer Details
    marko_ribar's Computer Details
    Operating System:
    Windows 7 Ultimate X64
    Computer:
    Intel quad core CPU 4x2.66GHz, 8GB RAM
    Motherboard:
    INTEL compatibile
    CPU:
    quad core 4x2.66GHz
    RAM:
    8GB
    Graphics:
    NVIDIA GeForce 6600 GT
    Primary Storage:
    250 GB
    Secondary Storage:
    500 GB
    Monitor:
    Samsung 17''
    Discipline
    Architectural
    marko_ribar's Discipline Details
    Occupation
    Architecture, project designer, project visualisation
    Discipline
    Architectural
    Details
    space design - modeling and animations
    Using
    AutoCAD 2012
    Join Date
    Feb 2010
    Location
    Belgrade, Serbia, Europe
    Posts
    338

    Default

    Registered forum members do not see this ad.

    I tried to replicate case OP posted in jpg, and with your original it wrongly filleted last line with arc but only on left portion - one pick boundary; right one it did correctly... I suppose it has something with fillet - it don't know how to connect entities (line filleted with arc extending it to make almost whole circle) when they are supplied rather then mid points like in my modification...

    Marko Ribar, d.i.a. (graduated engineer of architecture)
    M.R. on YouTube

Similar Threads

  1. Fillets
    By apowersite in forum AutoCAD Beginners' Area
    Replies: 18
    Last Post: 11th Jul 2011, 12:49 am
  2. Fillets and Curves
    By langum25 in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 4th Apr 2011, 07:11 pm
  3. Replies: 3
    Last Post: 10th Aug 2010, 04:39 am
  4. Dimensioning Fillets
    By bradbb2005 in forum Tutorials & Tips'n'Tricks
    Replies: 7
    Last Post: 21st Apr 2010, 05:25 pm
  5. Drawings and Fillets
    By Toolish in forum Autodesk Inventor
    Replies: 9
    Last Post: 19th Dec 2009, 05:30 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts