Mledit lisp

Discussion in 'AutoCAD' started by Erik Deyo, Jul 13, 2004.

  1. Erik Deyo

    Erik Deyo Guest

    I was wondering if someone has a lisp that would let me select multiple
    mlines to be trimmed by one mline could someone help me?

    Thanks in advance,

    Erik
     
    Erik Deyo, Jul 13, 2004
    #1
  2. Erik Deyo

    David Kozina Guest

    Erik,
    Be more specific.
    Trimmed how? Open Tee? Closed Tee? Open Cross? Closed Cross?
    Is it always the same sort of editing procedure/sequence? How?

    I've found that just abbreviating the -mledit command line options are
    sufficient for most things...

    ; Run command with options
    ; Ugly command function
    (defun djkDoCommand
    (Name_str ; Command Name String - caller to provide "_."
    prefix
    PauseOrAutoEnter_value ; PAUSE or "" - Let user finish or Autoterminate
    Input_lst ; Preset command option list - may be nil
    /
    ;
    )
    ; begin
    ; start command
    (command Name_str)
    ; ...Option list provided?
    (if Input_lst
    ; then
    ; ...process command options
    (foreach CommandOption Input_lst;
    ; begin loop
    (command CommandOption)
    ; end loop
    );_end foreach
    ; else
    );_end if
    ; did caller use a "." command prefix?
    ; - now remove it for cmdnames usage below
    (setq Name_str
    (vl-string-subst
    ""
    "."
    Name_str
    )
    );_end setq
    ; did caller use a "_" command prefix?
    ; - now remove it for cmdnames usage below
    (setq Name_str
    (vl-string-subst
    ""
    "_"
    Name_str
    )
    );_end setq
    ; ...is command still active? - it needs to finish
    (while
    (wcmatch
    (getvar "CMDNAMES")
    (strcat "*" Name_str "*")
    )
    ; begin loop
    (command PauseOrAutoEnter_value)
    ; end loop
    );_end while
    ; end
    );_end defun


    ; Run MLEdit Command with Option
    ; (Used in MLEDIT Wrapper functions below)
    (defun djkRunMLEditOption
    (CommandOptionInput_str ; Command Option used for MLEDIT function
    /
    ;
    )
    ; begin
    (djkDoCommand
    "_.-MLEDIT"
    PAUSE
    (list CommandOptionInput_str)
    )
    (princ)
    ; end
    );_end defun


    ; Abbreviate MLEDIT Add Vertex
    (defun C:MAV ()
    ; begin
    (djkRunMLEditOption "AV")
    ; end
    );_end defun

    ; Abbreviate MLEDIT Cut All
    (defun C:MCA ()
    ; begin
    (djkRunMLEditOption "CA")
    ; end
    );_end defun

    ; Abbreviate MLEDIT Closed Cross
    (defun C:MCC ()
    ; begin
    (djkRunMLEditOption "CC")
    ; end
    );_end defun

    ; Abbreviate MLEDIT Corner Joint
    (defun C:MCJ ()
    ; begin
    (djkRunMLEditOption "CJ")
    ; end
    );_end defun

    ; Abbreviate MLEDIT Cut Single
    (defun C:MCS ()
    ; begin
    (djkRunMLEditOption "CS")
    ; end
    );_end defun

    ; Abbreviate MLEDIT Closed Tee
    (defun C:MCT ()
    ; begin
    (djkRunMLEditOption "CT")
    ; end
    );_end defun

    ; Abbreviate MLEDIT Delete Vertex
    (defun C:MDV ()
    ; begin
    (djkRunMLEditOption "DV")
    ; end
    );_end defun

    ; Abbreviate MLEDIT Merged Cross
    (defun C:MMC ()
    ; begin
    (djkRunMLEditOption "MC")
    ; end
    );_end defun

    ; Abbreviate MLEDIT Merged Tee
    (defun C:MMT ()
    ; begin
    (djkRunMLEditOption "MT")
    ; end
    );_end defun

    ; Abbreviate MLEDIT Open Cross
    (defun C:MOC ()
    ; begin
    (djkRunMLEditOption "OC")
    ; end
    );_end defun

    ; Abbreviate MLEDIT Open Tee
    (defun C:MOT ()
    ; begin
    (djkRunMLEditOption "OT")
    ; end
    );_end defun

    ; Abbreviate MLEDIT Weld All
    (defun C:MWA ()
    ; begin
    (djkRunMLEditOption "WA")
    ; end
    );_end defun
     
    David Kozina, Jul 13, 2004
    #2
  3. Erik Deyo

    Erik Deyo Guest

    I'm looking for a closed cross appication, I have many intersecting mlines
    and I would like to trim all the horizontal ones around the vertical.
     
    Erik Deyo, Jul 13, 2004
    #3
  4. Erik Deyo

    David Kozina Guest

    Typing while thinking out loud and *quite* untested...
    Hope it's at least within the ballpark...
    Use/Modify at your own risk... ;)

    hth,
    David Kozina

    (defun C:MLCCTRIM
    ( ;
    /
    VertML_ent ; Vertical MLine entity
    HorizML_ss ; Selection set of Horizontal MLines
    )
    ; begin
    ; select the vertical mline entity
    (setq VertML_ent
    (car (entsel "\nPick the Vertical MLine..."))
    );_end setq
    ; select the horizontal mlines
    (princ "/nSelect the Horizontal MLines to trim...")
    (setq HorizML_ss
    (ssget '((0 . "MLINE")))
    );_end setq
    (if
    (and
    VertML_ent
    (not (zerop (setq i (sslength HorizML_ss))))
    )
    ; then go for it
    (while (<= 0 i)
    ; begin loop
    ; I can't remember which pick should come first,
    ; switch the semicolon on the next two lines if need be...
    ; (command "_.-MLEDIT" "CC" (ssname HorizML_ss i) VertML_ent)
    (command "_.-MLEDIT" "CC" VertML_ent (ssname HorizML_ss i))
    (setq i (1- i))
    ; end loop
    );_end while
    ; else bad user input
    ;
    );_end if
    (princ)
    ; end
    );_end defun
     
    David Kozina, Jul 13, 2004
    #4
  5. Erik Deyo

    David Kozina Guest

    The last routine probably has some bad indexing problems (at least!)
    So, how about... (I still have my doubts, but it may be closer):

    (defun C:MLCCTRIM
    ( ;
    /
    VertML_ent ; Vertical MLine entity
    HorizML_ss ; Selection set of Horizontal MLines
    )
    ; begin
    ; select the vertical mline entity
    (setq VertML_ent
    (car (entsel "\nPick the Vertical MLine..."))
    );_end setq
    ; select the horizontal mlines
    (princ "/nSelect the Horizontal MLines to trim...")
    (setq HorizML_ss
    (ssget '((0 . "MLINE")))
    );_end setq
    (if
    (and
    VertML_ent
    HorizML_ss
    (not (zerop (setq i (sslength HorizML_ss))))
    )
    ; then go for it
    (while (< 0 i)
    ; begin loop
    (setq i (1- i))
    ; I can't remember which pick should come first,
    ; switch the semicolon on the next two lines if need be...
    ; (command "_.-MLEDIT" "CC" (ssname HorizML_ss i) VertML_ent)
    (command "_.-MLEDIT" "CC" VertML_ent (ssname HorizML_ss i))
    ; end loop
    );_end while
    ; else bad user input
    ;
    );_end if
    (princ)
    ; end
    );_end defun
     
    David Kozina, Jul 13, 2004
    #5
  6. Erik Deyo

    David Kozina Guest

    Well, that last one didn't work either - so how 'bout...:

    (defun C:MLCCTRIM
    ( ;
    /
    i ; index counter
    HorizML_ss ; Selection set of Horizontal MLines
    VertML_ent ; Vertical MLine entity
    )
    ; begin
    ; select the vertical mline entity
    (setq VertML_ent
    (car (entsel "\nPick the Vertical MLine..."))
    );_end setq
    ; select the horizontal mlines
    (princ "\nSelect the Horizontal MLines to trim...")
    (setq HorizML_ss
    (ssget '((0 . "MLINE")))
    );_end setq
    (if
    (and
    VertML_ent
    HorizML_ss
    (not (zerop (setq i (sslength HorizML_ss))))
    )
    ; then go for it
    (while (< 0 i)
    ; begin loop
    (setq i (1- i))
    ; I can't remember which pick should come first,
    ; switch the semicolon on the next two lines if need be...
    (command "_.-MLEDIT" "CC" (ssname HorizML_ss i) VertML_ent "")
    ;(command "_.-MLEDIT" "CC" VertML_ent (ssname HorizML_ss i) "")
    ; end loop
    );_end while
    ; else bad user input
    ;
    );_end if
    (princ)
    ; end
    );_end defun
     
    David Kozina, Jul 13, 2004
    #6
  7. Erik Deyo

    Erik Deyo Guest

    It worked thank you so much. that will save me about 20 minutes per drawing.
    thank you again
     
    Erik Deyo, Jul 14, 2004
    #7
  8. Erik Deyo

    David Kozina Guest

    Hey Erik,

    *I'm* just happy to see someone using mlines! ;)

    Note that the code I posted could probably benefit from some major
    optimizing, but I'm glad it helps you...

    A couple of more thoughts on how you might improve on it:

    Allow the user to input/choose the mledit option (at least those that
    require picks of two mlines): "CC" "OC" "CT" "OT", etc., then incorporate
    that option variable into the (command... statement, and then just call the
    routine MLTRIM.

    Perhaps rebuild the while loop to first create a (long) list of alternating
    entities...
    ((ssname HorizML_ss i) VertML_ent (ssname HorizML_ss (i-1)) VertML_ent
    (ssname HorizML_ss (i-2)) VertML_ent)...) ... Then process the command
    using this list for input (as in the djkDoCommand function I first posted in
    response to this thread) - That way the (command... only needs to run once,
    rather than restarting time after time...

    Best regards,
    David Kozina
     
    David Kozina, Jul 14, 2004
    #8
  9. Erik Deyo

    trunglupin

    Joined:
    Aug 28, 2014
    Messages:
    1
    Likes Received:
    0
    MLEDIT for open intersec

    my case is with open cross and open T for many multiline intersections.
    The command -mledit of your code above is very good but is there any way for many intersects?

    Do you have any suggestion?
    Tks in advance.
     
    trunglupin, Aug 28, 2014
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.