Some help refining a offset and boundary lisps

Some help refining a offset and boundary lisps

Satoews
Advocate Advocate
1,009 Views
12 Replies
Message 1 of 13

Some help refining a offset and boundary lisps

Satoews
Advocate
Advocate

Hello again!

 

I think my brain is fried at this point and I would like someone to take a fresh look at what I can do better.

 

(defun c:OOF ( / )
    (command
	  "offset" pause pause (setq ss (getpoint "\nspecify point on side to offset multiple lines :")) ss
	    (while
	      (> (getvar 'cmdactive) 0) 
		    (SETQ ENT (ENTLAST))
		    (SSADD ENT ESMTLIST)
		    (command pause ss )		  
	    )
    )
)


(DEFUN C:BOO(/)
  (COMMAND 
  "BOUNDARY" PAUSE ""
  "ERASE" ESMTLIST ""
  )
)

(defun c:TEST3 (/)
    (setq LVL (SSGET "X" '((100 . "AeccDbFace"))))
)

 

I am trying to get the oof commands selection set esmtlist to span thru commands I can't seem to get that to work except for setting esmtlist out of the command.

 

I don't think there is anything wrong with the boo command but i wanted to show you why i wanted to span the selection set.

 

Lastly there is command test 3, I have a "aeccdbface" entity that is in the middle of the object I am offsetting lines in. Is there any way i can use that object coordinates to skipp the SS selection set?

 

As always thanks in advance

 

Shawn T
0 Likes
Accepted solutions (1)
1,010 Views
12 Replies
Replies (12)
Message 2 of 13

Kent1Cooper
Consultant
Consultant

A quick stab at the OOF part:

 

It won't allow you to add objects to a selection set that does not yet exist.  Try starting the ESMTLIST variable as an empty selection set before the (command "offset"...  part begins:

 

(setq ESMTLIST (ssadd))

 

On the test3 part:

[Your ss isn't a "selection set," though that's the kind of variable that name is usually used for -- I would suggest changing the name.]  What is the nature of the AeccDbFace object?  Is it like an AcDbFace object, such as the 3DFACE command makes?  Can you apply (entget) to it, and get a point from its entity data?  If so, it should be possible to use that in the Offset command so the User doesn't need to pick something for your ss variable.

Kent Cooper, AIA
Message 3 of 13

Satoews
Advocate
Advocate

DOSEN'T THAT WIPE THE PREVIOUS ESMTLIST SELECTION SET THOUGH? MAYBE AN IF STATEMENT TO SEE IF THE SELECTION SET IS ALREADY THERE? THAT COULD WORK, RIGHT?

 

 

Shawn T
0 Likes
Message 4 of 13

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

DOSEN'T THAT WIPE THE PREVIOUS ESMTLIST SELECTION SET THOUGH? MAYBE AN IF STATEMENT TO SEE IF THE SELECTION SET IS ALREADY THERE? THAT COULD WORK, RIGHT?


Yes.

 

(if (not esmtlist) (setq esmtlist (ssadd)))

Kent Cooper, AIA
Message 5 of 13

Satoews
Advocate
Advocate

OOF FIX WORKED WONDERFULLY, THANK YOU.

 

TEST3 IS A PARCEL AREA LABEL, I CAN GET THE COORD DATA WITH (ENTSEL) AT LEAST I THINK THATS WHAT I AM GETTING.

 

 

Command: (ENTSEL)
Select object: (<Entity name: 7ffffb55230> (25935.9 21091.0 0.0))

 

 

(defun c:oof ( / osp ent )
(if
(not esmtlist)
(setq esmtlist (ssadd))
)
(command
"offset" pause pause (setq osp (getpoint "\nspecify point on side to offset multiple lines :")) osp
(while
(> (getvar 'cmdactive) 0)
(setq ent (entlast))
(ssadd ent esmtlist)
(command pause osp )
)
)
)


(defun c:boo(/)
(command
"boundary" pause ""
"erase" esmtlist ""
)
)

(defun c:test3 (/)
(setq lvl (ssget "x" '((100 . "aeccdbface"))))
)

 

Shawn T
0 Likes
Message 6 of 13

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

OOF FIX WORKED WONDERFULLY, THANK YOU.

 

TEST3 IS A PARCEL AREA LABEL, I CAN GET THE COORD DATA WITH (ENTSEL) AT LEAST I THINK THATS WHAT I AM GETTING.

 

 

Command: (ENTSEL)
Select object: (<Entity name: 7ffffb55230> (25935.9 21091.0 0.0))

 

 

(defun c:OOF ( / SS ENT )
  (IF
    (NOT ESMTLIST)
	  (setq ESMTLIST (ssadd))
  )
    (command
	  "offset" pause pause (setq OSP (getpoint "\nspecify point on side to offset multiple lines :")) OSP ; why OSP twice?
	    (while
	      (> (getvar 'cmdactive) 0) 
		    (SETQ ENT (ENTLAST))
		    (SSADD ENT ESMTLIST)
		    (command pause ss )	 ; if you miss the line, you're screwed! BTW is ss the point (OSP)?  
	    )
    )
)

 


 

Not sure if that works... (it fails to me)... If you want try this code... it should be more bulletproof...

 

Spoiler
(defun c:oof2 ( / ss pt ent i dist)
  (if (and (setq dist (getdist "\nSpecify distance: "))
	   (setq pt (getpoint "\nSpecify side: "))
	   (setq ent (entlast))
	   (or *ss
	       (setq *ss (ssadd)))
	   (princ "\nNeed lines, ")
	   (setq ss (ssget '((0 . "LINE"))))
	   )
    (repeat (setq i (sslength ss))
      (command "_.offset" dist (ssname ss (setq i (1- i))) pt "")
	(if (not (equal ent (entlast)))
	  (ssadd (setq ent (entlast)) *ss)))
  )
  (princ)
)

(defun c:boo2 nil
  (if *ss
    (command
      "_.boundary" pause ""
      "_.erase" *ss ""
    )
  )
  (princ)
)

PS. please don't use ss for anything but selection set 🙂

Message 7 of 13

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... 

TEST3 IS A PARCEL AREA LABEL, I CAN GET THE COORD DATA WITH (ENTSEL) AT LEAST I THINK THATS WHAT I AM GETTING.

 

Command: (ENTSEL)
Select object: (<Entity name: 7ffffb55230> (25935.9 21091.0 0.0))

No, that's the point at which you picked it.  Note the difference between what is returned by (entsel) and (entget).  Try:

 

(entget (car (entsel "\nPick one of those babies: ")))

 

and see whether that returns something that has an insertion point.

Kent Cooper, AIA
Message 8 of 13

Satoews
Advocate
Advocate

Ah ok, in that case i don't think it has any sort of insertion point. This is all I am getting from the list.

 

Pick one of those babies: ((-1 . <Entity name: 7ffffb93390>)
(0 . "AECC_PARCEL") (330 . <Entity name: 7ffffb039f0>) (5 . "16221")
(100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "Lot line")
(100 . "AeccDbEntity") (100 . "AeccDbFace"))
Shawn T
0 Likes
Message 9 of 13

Satoews
Advocate
Advocate

Thanks that works and noted for the future on "SS".

On my code:

I was editing it and forgot to replace the last ss in the lisp.

On adding the second osp after the getpoint i didn't know the (setq) could perform double duty, i thought i had to set it and also used as the variable after setting.

 

thanks!

 

Shawn Toews

 

Shawn T
0 Likes
Message 10 of 13

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

... i didn't know the (setq) could perform double duty...


That's what the LISP is all about... EACH function has this "double duty"... each function returns something (if, and, cond, .... command, intiget...). And it's important to know what - see the help, where this it always mentioned.

Message 11 of 13

Satoews
Advocate
Advocate

after some testing with the other drafters they didn't like the way it was asking for entities with ssget. So with the education of this post I took the weekend and messed around with the code to get it to pretty closely mimic the way autocadd dose the offset command. This in turn though braught up new questions.

 

(defun c:oof3 ( / ent2 )
  (if
    (not esmtlist)
    (setq esmtlist (ssadd))
  ) 
  	(SETQ DIST1 (getdist "\nspecify distance of offset:"))  
        (WHILE 
(NULL (setq en1 (entsel "\nselect object to offset:")))) (setq osp (getpoint "\nspecify point on side to offset multiple lines :")) (command);; why do i need so I don't have _.offset printing in my previous line? (command "_.offset" DIST1 EN1 OSP) (while (setq ent (entlast)) (ssadd ent esmtlist) (while
(null (setq en2(entsel "\nselect object to offset:"))))
;; is there a way to adjust the code to if the user imputs in a number it adjusts the dist1 var but will keep selecting entities if you'd like? (command);; this one too, shouldn't it get out of the command cleanly after the previous line returns not null? (command "_.offset" dist1 en2 osp)
) (princ) ) (defun c:boo(/) (command "boundary" osp "" "erase" esmtlist "" ) )

as always thanks in advance and thank you for your previous posts.

 

Shawn Toews

 

Shawn T
0 Likes
Message 12 of 13

ВeekeeCZ
Consultant
Consultant
Accepted solution

Perhaps like this...

 

Spoiler
(defun c:oof4 ( / dist ensel done osp)

  (or esmtlist
      (setq esmtlist (ssadd)))
 

  (while (not done)

    (or dist
	(initget 1)
	(setq dist (getdist "\nSpecify distance of offset: ")))
    
    (setvar 'ERRNO 0)
    (initget "Distance")
    (setq ensel (entsel "\nSelect object to offset [Distance]: "))  ; hit enter to end
    
    (cond ((= ensel "Distance") ; set distance
	   (setq dist nil))
	  
	  ((and (not ensel)	; ended by enter
		(eq (getvar 'ERRNO) 52))
	   (setq done T))
	  
	  ((not ensel))		; missed
	  
	  ((wcmatch (cdr (assoc 0 (entget (car ensel)))) "~LINE")) ; selected anything but LINE
	  
	  (ensel 		; correct selection
	   
	   (or osp
	       (setq osp (getpoint "\nSpecify point on side to offset multiple lines: ")))
	   
	   (command "_.OFFSET" dist (car ensel) osp "")
	   
	   (ssadd (entlast) esmtlist)
	   )))
  (princ)
)

 

Message 13 of 13

Satoews
Advocate
Advocate
Perfect! thanks!
Shawn T
0 Likes