trying to join two arcs w/ PEDIT

Discussion in 'AutoCAD' started by biot023, Oct 21, 2004.

  1. biot023

    biot023 Guest

    Hallo - I can't get PEDIT to work with two entities using the command subr.
    The process I go through at the command line is:
    PEDIT
    <sel arc1>
    <RETURN>
    "y" -- in response to question do I wish to turn into polyline
    "Join"
    <sel arc2>
    <RETURN>
    <RETURN>

    This is fine for joining the arcs, but I cannot seem to express it in code.
    I've tried:
    (command "PEDIT" ent1 "" "y" "Join" ent2 "" "")

    And other variations, but don't seem to get anywhere.
    Does anyone have any ideas why?
    Cheers,
    doug.
     
    biot023, Oct 21, 2004
    #1
  2. biot023

    Dann Guest

    (setq ent1(entsel "\nSelect first object: "))
    (setq ent2(entsel "\nSelect second object: "))
    (command "PEDIT" ent1 "y" "j" ent1 ent2 "" "")
    (princ)
     
    Dann, Oct 21, 2004
    #2
  3. biot023

    Joe Burke Guest

    Doug,

    Under 2004 and previous 200x versions the command line prompts vary depending on
    whether the objects selected for joining include lines and/or arcs or only plines
    (heavy or light weight). I think this changed under 2005, but I'm not sure. Changed
    in the sense the question about convert line/arcs was eliminated. Maybe someone using
    2005 will confirm, or say it ain't so.

    So a program which deals with whatever is selected (pre 2005) should look something
    like this given a selection set.

    (setq SS (ssget))
    (if (ssget "P" '((0 . "ARC,LINE"))) ;test if previous SS contains arcs and/or lines
    (command "pedit" "M" SS "" "Y" "J" "J" "B" pause "") ;pause for fuzz
    (command "pedit" "M" SS "" "J" "J" "B" pause "")
    )

    HTH
    Joe Burke
     
    Joe Burke, Oct 21, 2004
    #3
  4. Hi Joe,

    Yes, in 2005 there is a system variable called PEDITACCEPT that will
    suppress the prompt, it says in help:

    Type: Integer
    Saved in: Registry
    Initial value: 0
    Suppresses display of the Object Selected Is Not a Polyline prompt in PEDIT.
    The prompt is followed by "Do you want it to turn into one?" Entering y
    converts the selected object to a polyline. When the prompt is suppressed,
    the selected object is automatically converted to a polyline.


    0 The prompt is displayed

    1 The prompt is suppressed



    So starting from what you have and the objects are contiguous, and in a
    nutshell, this seems to work...

    (defun c:J ( / PdtAcc ss)
    (progn
    (setq PdtAcc (getvar "PEDITACCEPT"))
    (setvar "PEDITACCEPT" 1)
    (setq ss (ssget))
    (if ss
    (progn
    (command "_.pedit" "M" ss "" "J" "" "")
    (setvar "PEDITACCEPT" PdtAcc)
    (princ "Attempting to join.")
    )
    (princ "...Nope.")
    )
    )
    (princ)
    )

    There are lots more to the PEDIT command that is not used here, such as a
    fuzz factor in the Join subroutine. Anyway, hope this helps biot023 some.

    Arnold Williams
     
    Arnold Williams, Oct 21, 2004
    #4
  5. biot023

    Joe Burke Guest

    Arnold,

    Thanks for the confirmation. Someday I'll get around to installing 2005.

    BTW, you wouldn't want make resetting the peditaccept var dependant on whether a
    selection set is found. Maybe something like this, or use an error handler to reset
    the var.

    (defun c:J ( / PdtAcc ss)
    (setq PdtAcc (getvar "PEDITACCEPT"))
    (setvar "PEDITACCEPT" 1)
    (if (setq ss (ssget))
    (progn
    (command "_.pedit" "M" ss "" "J" "" "")
    (princ "Attempting to join.")
    )
    (princ "...Nope.")
    )
    (setvar "PEDITACCEPT" PdtAcc)
    (princ)
    )

    Joe Burke
     
    Joe Burke, Oct 21, 2004
    #5
  6. Joe,

    Yes, I do not consider myself a proficient programmer, just a designer with
    the need to customize. My coffee did not kick in yet when I did this stuff,
    noticed later a progn that was not necessary also.

    Will have to look more into this error handler business, some of my best
    stuff needs a good error workout - my best stuff is probably not that good -
    but still needs error handling. So thanks for that. Will also look at
    rearranging the variable after a selection is made. Good one, usually I
    have done it that way. I am sticking to my coffee story though.

    biot023... is this helping any?

    Arnold
     
    Arnold Williams, Oct 21, 2004
    #6
  7. biot023

    biot023 Guest

    This is all fantastic, cheers!
    I've got a rather old version of AutoCAD to work with, so I'm gonna have to have a play w/ the various suggestions here & let you all know how it goes.
    Once again, thanks for the fantastic response!
    doug.
     
    biot023, Oct 22, 2004
    #7
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.