Jump to content
waders

Joining 2 commands

Recommended Posts

waders

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

[size=3][font=Calibri](defun c:heal2  (/ block ll ur p1 p2)[/font][/size]
[size=3][font=Calibri]     (vl-load-com)[/font][/size]
[size=3][font=Calibri]     (setq block (car (entsel "\nSelect Block:")))[/font][/size]
[size=3][font=Calibri]     (vla-getboundingbox (vlax-ename->vla-object block) 'll 'ur)[/font][/size]
[size=3][font=Calibri]     (command "_.erase" block "")[/font][/size]
[size=3][font=Calibri]     (command[/font][/size]
[size=3][font=Calibri]           "_.pedit"[/font][/size]
[size=3][font=Calibri]           "_m"[/font][/size]
[size=3][font=Calibri]           (ssget "C"[/font][/size]
[size=3][font=Calibri]                  (setq p1 (vlax-safearray->list ll))[/font][/size]
[size=3][font=Calibri]                  (setq p2 (vlax-safearray->list ur)))[/font][/size]
[size=3][font=Calibri]           ""[/font][/size]
[size=3][font=Calibri]           "_join" "_Joint" "_Both"[/font][/size]
[size=3][font=Calibri]           (distance p1 p2)[/font][/size]
[size=3][font=Calibri]           "")[/font][/size]
[size=3][font=Calibri]     (princ)[/font][/size]
[size=3][font=Calibri]     )[/font][/size]

[size=3][font=Calibri](defun c:HEAL (/ block ll ur objecttojoin)[/font][/size]
[size=3][font=Calibri]     (vl-load-com)[/font][/size]
[size=3][font=Calibri]     (setq block (car (entsel "\nSelect Block:")))[/font][/size]
[size=3][font=Calibri]     (vla-getboundingbox (vlax-ename->vla-object block) 'll 'ur)[/font][/size]
[size=3][font=Calibri]     (command "_.erase" block "")[/font][/size]
[size=3][font=Calibri]     (setq objecttojoin[/font][/size]
[size=3][font=Calibri]                (ssget "C"[/font][/size]
[size=3][font=Calibri]                       (vlax-safearray->list ll)[/font][/size]
[size=3][font=Calibri]                       (vlax-safearray->list ur)))[/font][/size]
[size=3][font=Calibri]     (command[/font][/size]
[size=3][font=Calibri]           "_.join"[/font][/size]
[size=3][font=Calibri]           (ssname objecttojoin 0)[/font][/size]
[size=3][font=Calibri]           (ssname objecttojoin 1)[/font][/size]
[size=3][font=Calibri]           "")[/font][/size]
[size=3][font=Calibri]     )[/font][/size]

Share this post


Link to post
Share on other sites
pBe

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

 

(defun c:heal2  (/ block pea ll ur p1 p2)
    (vl-load-com)
[color="blue"]     (setq pea (getvar 'Peditaccept))  
    (setvar 'PeditAccept 1)[/color]
    (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)
          "")
   [b][color="blue"] (setvar 'PeditAccept pea)[/color][/b]
    (princ)
    )

Share this post


Link to post
Share on other sites
waders

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:

(cond
 ((= $ent2 line)(c:heal))
 ((= $ent2 lwpolyline)(c:heal2))
)

$ent2 would be either line or lwpolyline pending which on is picked.

Share this post


Link to post
Share on other sites
pBe
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.

 

But shouldn't I be able to add a:

(cond
 ((= $ent2 line)(c:heal))
 ((= $ent2 lwpolyline)(c:heal2))
)

$ent2 would be either line or lwpolyline pending which on is picked.

 

(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 "")
   [color="blue"][b] (setq objs[/b][/color] (ssget "C"
                 (setq p1 (vlax-safearray->list ll))
                 (setq p2 (vlax-safearray->list ur))))
(if [b][color="blue"](eq (cdr (assoc 0 (entget (ssname objs 0)))) "LWPOLYLINE")[/color][/b]	   
    (command "_.pedit" "_m" [b][color="blue"]objs[/color][/b] "" "_join" "_Joint" "_Both"
          (distance p1 p2) "")
    (command "_.join" (ssname [color="blue"][b]objs[/b][/color] 0) (ssname [b][color="blue"]objs [/color][/b]1) "")
    )
 (setvar 'PeditAccept pea)
 (princ)
 )

Share this post


Link to post
Share on other sites
waders

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.

Share this post


Link to post
Share on other sites
pBe
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.

 

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

Share this post


Link to post
Share on other sites
waders

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

 

(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)
)

Share this post


Link to post
Share on other sites
pBe

lets try something

 

(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)
 [color="blue"](if [/color](setq $blk (ssget '((0 . "insert"))))
 [color="blue"] (repeat (setq i (sslength $blk))
    	(setq e (ssname  $blk (setq i (1- i))))[/color]
  	(vla-getboundingbox (vlax-ename->vla-object e) 'll 'ur)
    	[color="blue"](entdel e)[/color]
  (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) "")
	[color="blue"])
    )
   (princ "\nNo Blocks Selected")
   )[/color]
  (setvar 'PeditAccept pea)
  (princ)
)

 

See if you can use that as reference.

This is CAD Tutor after all ;)

Edited by pBe

Share this post


Link to post
Share on other sites
waders

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.

 

(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)
)

Share this post


Link to post
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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