+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Full Member waders's Avatar
    Computer Details
    waders's Computer Details
    Operating System:
    Windows 7 Pro
    Computer:
    Snail
    RAM:
    8g
    Graphics:
    ATI FirePro V5800 DVI
    Monitor:
    (2) 20" Dell 2001FP
    Discipline
    Architectural
    waders's Discipline Details
    Occupation
    Design Tech III
    Discipline
    Architectural
    Using
    AutoCAD 2011
    Join Date
    Mar 2010
    Location
    Rochester, MN
    Posts
    37

    Default Joining 2 commands

    Registered forum members do not see this ad.

    Okay this seems like a simple one. How would I join these 2 commands so it doesn't matter if the line is a line or pline. Thanks
    Code:
    (defun c:heal2  (/ block ll ur p1 p2)
         (vl-load-com)
         (setq block (car (entsel "\nSelect Block:")))
         (vla-getboundingbox (vlax-ename->vla-object block) 'll 'ur)
         (command "_.erase" block "")
         (command
               "_.pedit"
               "_m"
               (ssget "C"
                      (setq p1 (vlax-safearray->list ll))
                      (setq p2 (vlax-safearray->list ur)))
               ""
               "_join" "_Joint" "_Both"
               (distance p1 p2)
               "")
         (princ)
         )
    Code:
    (defun c:HEAL (/ block ll ur objecttojoin)
         (vl-load-com)
         (setq block (car (entsel "\nSelect Block:")))
         (vla-getboundingbox (vlax-ename->vla-object block) 'll 'ur)
         (command "_.erase" block "")
         (setq objecttojoin
                    (ssget "C"
                           (vlax-safearray->list ll)
                           (vlax-safearray->list ur)))
         (command
               "_.join"
               (ssname objecttojoin 0)
               (ssname objecttojoin 1)
               "")
         )

  2. #2
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    If you don't mind converting the lines to plines , you can use heal2 for both if you set peditaccept to 1

    Code:
    (defun c:heal2  (/ block pea ll ur p1 p2)
         (vl-load-com)
         (setq pea (getvar 'Peditaccept))  
         (setvar 'PeditAccept 1)
         (setq block (car (entsel "\nSelect Block:")))
         (vla-getboundingbox (vlax-ename->vla-object block) 'll 'ur)
         (command "_.erase" block "")
         (command
               "_.pedit"
               "_m"
               (ssget "C"
                      (setq p1 (vlax-safearray->list ll))
                      (setq p2 (vlax-safearray->list ur)))
               ""
               "_join" "_Joint" "_Both"
               (distance p1 p2)
               "")
         (setvar 'PeditAccept pea)
         (princ)
         )

  3. #3
    Full Member waders's Avatar
    Computer Details
    waders's Computer Details
    Operating System:
    Windows 7 Pro
    Computer:
    Snail
    RAM:
    8g
    Graphics:
    ATI FirePro V5800 DVI
    Monitor:
    (2) 20" Dell 2001FP
    Discipline
    Architectural
    waders's Discipline Details
    Occupation
    Design Tech III
    Discipline
    Architectural
    Using
    AutoCAD 2011
    Join Date
    Mar 2010
    Location
    Rochester, MN
    Posts
    37

    Default

    First of all thanks pBe for looking at this.
    If I had my choice I would like to convert plines into lines the join. But shouldn't I be able to add a:
    Code:
    (cond
      ((= $ent2 line)(c:heal))
      ((= $ent2 lwpolyline)(c:heal2))
    )
    $ent2 would be either line or lwpolyline pending which on is picked.

  4. #4
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    Quote Originally Posted by waders View Post
    First of all thanks pBe for looking at this.
    If I had my choice I would like to convert plines into lines the join.
    Its either you explode the selection to turn it to lines then join or use heal2 then explode.

    Quote Originally Posted by waders View Post
    But shouldn't I be able to add a:
    Code:
    (cond
      ((= $ent2 line)(c:heal))
      ((= $ent2 lwpolyline)(c:heal2))
    )
    $ent2 would be either line or lwpolyline pending which on is picked.
    Code:
    (defun c:heald  (/ pea block ll ur objs p1 p2)
         (vl-load-com)
    (setq pea (getvar 'Peditaccept))  
         (setvar 'PeditAccept 1)  
         (setq block (car (entsel "\nSelect Block:")))
         (vla-getboundingbox (vlax-ename->vla-object block) 'll 'ur)
         (command "_.erase" block "")
         (setq objs (ssget "C"
                      (setq p1 (vlax-safearray->list ll))
                      (setq p2 (vlax-safearray->list ur))))
    (if (eq (cdr (assoc 0 (entget (ssname objs 0)))) "LWPOLYLINE")	   
         (command "_.pedit" "_m" objs "" "_join" "_Joint" "_Both"
               (distance p1 p2) "")
         (command "_.join" (ssname objs 0) (ssname objs 1) "")
         )
      (setvar 'PeditAccept pea)
      (princ)
      )

  5. #5
    Full Member waders's Avatar
    Computer Details
    waders's Computer Details
    Operating System:
    Windows 7 Pro
    Computer:
    Snail
    RAM:
    8g
    Graphics:
    ATI FirePro V5800 DVI
    Monitor:
    (2) 20" Dell 2001FP
    Discipline
    Architectural
    waders's Discipline Details
    Occupation
    Design Tech III
    Discipline
    Architectural
    Using
    AutoCAD 2011
    Join Date
    Mar 2010
    Location
    Rochester, MN
    Posts
    37

    Default

    Thank you pBe. That works great. I see how you did it, but know I just need to figure out how you came up with it. I'm going to see if I can figure out how to filter out to only select blocks. If I do I'll repost. Thanks again for your help.

  6. #6
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    Quote Originally Posted by waders View Post
    Thank you pBe. That works great. I see how you did it, but know I just need to figure out how you came up with it.
    Good for you, hope you'll learn from it. It is your code after all.

    Quote Originally Posted by waders View Post
    I'm going to see if I can figure out how to filter out to only select blocks.
    If you mean multiple selection in one-go. Yes, it can be done. Pretty sure you'll figure it out on your own. keep us posted

    Cheers

  7. #7
    Full Member waders's Avatar
    Computer Details
    waders's Computer Details
    Operating System:
    Windows 7 Pro
    Computer:
    Snail
    RAM:
    8g
    Graphics:
    ATI FirePro V5800 DVI
    Monitor:
    (2) 20" Dell 2001FP
    Discipline
    Architectural
    waders's Discipline Details
    Occupation
    Design Tech III
    Discipline
    Architectural
    Using
    AutoCAD 2011
    Join Date
    Mar 2010
    Location
    Rochester, MN
    Posts
    37

    Default Selecting more then one block

    Okay I got so I can select only a block. But if I select more then one block it only works on one an ignore's the others. How would I make it run for each item in the selection set? Thanks

    Code:
    (defun c:ee (/ pea $blk block ll ur objs p1 p2)
      (vl-load-com)
      (setq pea (getvar 'Peditaccept))
      (setvar 'PeditAccept 1)
      (setq $blk (ssget '((0 . "insert"))))
      (setq block (ssname $blk 0))
      (vla-getboundingbox (vlax-ename->vla-object block) 'll 'ur)
      (command "_.erase" block "")
      (setq objs (ssget "C" 
          (setq p1 (vlax-safearray->list ll))
          (setq p2 (vlax-safearray->list ur))
          )
      )
      (if (eq (cdr (assoc 0 (entget (ssname objs 0)))) "LWPOLYLINE")
        (command "_.pedit"
          "_m"
          objs
          ""
          "_join"
          "_Joint"
          "_Both"
          (distance p1 p2)
          ""
        )
        (command "_.join" (ssname objs 0) (ssname objs 1) "")
      )
      (setvar 'PeditAccept pea)
      (princ)
    )

  8. #8
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    lets try something

    Code:
    (defun c:hint ()
       (if	(setq ss (ssget '((0 . "INSERT"))))
       		(repeat (setq i (sslength ss))
    		  	(setq pt  (cdr
    				 (assoc  10
    				   (entget
    				     (setq e (ssname ss (setq i (1- i))))
    				   ))))
    		  	(command "_rotate" e "" "_non" pt "180")
    		  )
         )(princ)
       )
    
    Scroll down when you're ready
     |||
     |||
     |||
    \    /
      \/
     
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    (defun c:ee (/ pea $blk block i ll ur objs p1 p2)
      (vl-load-com)
      (setq pea (getvar 'Peditaccept))
      (setvar 'PeditAccept 1)
      (if (setq $blk (ssget '((0 . "insert"))))
    	  (repeat (setq i (sslength $blk))
    	    	(setq e (ssname  $blk (setq i (1- i))))
    	  	(vla-getboundingbox (vlax-ename->vla-object e) 'll 'ur)
    	    	(entdel e)
    	  (setq objs (ssget "C" 
    	      (setq p1 (vlax-safearray->list ll))
    	      (setq p2 (vlax-safearray->list ur))
    	      )
    	  )
    	(if (eq (cdr (assoc 0 (entget (ssname objs 0)))) "LWPOLYLINE")
    		  (command "_.pedit"  "_m"  objs
    			   ""  "_join" "_Joint"
    			   "_Both" (distance p1 p2)
    			   "" )
    		  (command "_.join" (ssname objs 0) (ssname objs 1) "")
    		)
    	    )
        (princ "\nNo Blocks Selected")
        )
    	  (setvar 'PeditAccept pea)
    	  (princ)
    	)
    See if you can use that as reference.
    This is CAD Tutor after all
    Last edited by pBe; 18th Oct 2012 at 03:15 pm.

  9. #9
    Full Member waders's Avatar
    Computer Details
    waders's Computer Details
    Operating System:
    Windows 7 Pro
    Computer:
    Snail
    RAM:
    8g
    Graphics:
    ATI FirePro V5800 DVI
    Monitor:
    (2) 20" Dell 2001FP
    Discipline
    Architectural
    waders's Discipline Details
    Occupation
    Design Tech III
    Discipline
    Architectural
    Using
    AutoCAD 2011
    Join Date
    Mar 2010
    Location
    Rochester, MN
    Posts
    37

    Default

    Registered forum members do not see this ad.

    Hey pbe, I think I got it not quite sure I understand why we need to us sslength and get the block's insertion point. But it does work. Thank you very much for you time.

    Code:
    (defun c:ee (/ pea $blk block ll ur objs p1 p2)
      (vl-load-com)
      (setq pea (getvar 'Peditaccept))
      (setvar 'PeditAccept 1)
      (if (setq $blk (ssget '((0 . "insert"))))
       (repeat (setq i (sslength $blk))
        (setq pt (cdr
          (assoc 10
           (entget
            (setq block (ssname $blk (setq i (1- i))))
          ))))
          (vla-getboundingbox (vlax-ename->vla-object block) 'll 'ur)
          (command "_.erase" block "")
          (setq objs (ssget "C"
       (setq p1 (vlax-safearray->list ll))
       (setq p2 (vlax-safearray->list ur))
       )
          )
          (if (eq (cdr (assoc 0 (entget (ssname objs 0)))) "LWPOLYLINE")
     (command "_.pedit"
       "_m"
       objs
       ""
       "_join"
       "_Joint"
       "_Both"
       (distance p1 p2)
       ""
     )
     (command "_.join" (ssname objs 0) (ssname objs 1) "")
          )
        );repeat
       );if
      (setvar 'PeditAccept pea)
      (princ)
    )

Similar Threads

  1. joining tables
    By gpd in forum AutoCAD General
    Replies: 5
    Last Post: 1st Sep 2011, 07:59 am
  2. Joining linetypes
    By johnengineer in forum AutoCAD Drawing Management & Output
    Replies: 6
    Last Post: 16th May 2007, 06:19 pm
  3. Joining Polylines
    By Rooster in forum AutoCAD Drawing Management & Output
    Replies: 8
    Last Post: 10th Oct 2005, 07:36 pm
  4. joining 3d faces
    By spyace in forum AutoCAD Beginners' Area
    Replies: 7
    Last Post: 28th Aug 2003, 09:10 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