Can I have a choice of actions when selecting 'OK'?

#1
I am continuing progress with this piping utility:
Image
.
All of the 'fittings' & 'Flanges' are complete and are working.


Up until now every choice resulted in an existing block (dwg) to be inserted into the active drawing.
I have added a new 'selection' item 'pipe' but the action here when selecting 'OK' will be to draw 2 concentric circles, extrude these to create 2 solid cylinders, subtract the smaller from the larger to create a section of pipe.

I have written the lisp to create the pipe, and this works as a stand alone lsp (in ICAD9.0 only??), but I would prefer to integrate this into the main utility.
see here: viewtopic.php?f=2&p=6937&sid=04d33132b5 ... 94fe#p6937

Unfortunately I'm not sure if this is achievable? as my attempts so far have failed :(


SteveN.

Re: Can I have a choice of actions when selecting 'OK'?

#3
Hi QuanNguyen and thank you for your reply.

I take from your post that I can have what I am trying to achieve, many thanks :)

What I am trying to achieve is a little more complicated in that, if you look at the image
when Pipe is selected (s7) this enables the 'Schedule' column.
when the appropriate schedule is chosen, (r41 - r49) the 'Sizes' box is populated
then when the required size is chosen the 'Dimensions' box is populated and the O/D & I/D is used in the 'Draw_Pipe_Shape' function. see code below.
Note: I have added your suggestions to the code.

Code: Select all

     (if (= NEWTILE "rb47")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb48")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb49")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if	
	(if (= NEWTILE "s7")
	(DRAW_PIPE_SHAPE)
  ) ;_ end of if
 ) ;end INSERT_BLOCK_VIEW
;-------------------------------------------------------------------------;

;-------------------------------------------------------------------------;
;----for ICAD 10.0 ONWARDS ONLY------
(defun DRAW_PIPE_SHAPE ( / spt1 spt2 dis ENT1 ENT2) 	; pipod pipid
 (if (and (setq spt1 (getpoint "\nSpecify Start point of Pipe"))
          (setq spt2 (getpoint "\nSpecify End point of Pipe"))
     ) ;end of AND
   (progn
	(command "ucs" "ZA" spt1 spt2)
	(command "circle" "0,0,0" "d" "120.00")
;	(command "circle" "0,0,0" "d" "pipod")		;take OD from dim file
		(setq ENT1 (entlast))
	(command "circle" "0,0,0" "d" "100.00")
;	(command "circle" "0,0,0" "d" "pipid")		;take ID from dim file
		(setq ENT2 (entlast))
		(setq dis (distance spt1 spt2)) 			;added from Nguyen
    (command "extrude" ENT1 "" dis "") 			;modified from Nguyen
		(setq ENT1 (entlast))
    (command "extrude" ENT2 "" dis "") 			;modified from Nguyen
		(setq ENT2 (entlast))
   	(command "subtract" ENT1 "" ENT2 "")	
   	(command "ucs" "_P")
    ) ;_ end of progn
   )  ;_ end of IF
) ;end DRAW_PIPE_SHAPE

Code: Select all

;-----------------------------------------------------------------------; 
	(action_tile "s7"				 						;toggle Pipe options
	(strcat
       "(setq newtile $key)"	
		"(L1_OFF)(L2_OFF)(L3_OFF)(L4_OFF)(L5_ON)
		(L1_CLEAR)(L2_CLEAR)(L3_CLEAR)(L4_CLEAR)(L5_CLEAR)
		(S7_FLAG)"
	); end strcat
	); END ACTION TILE
;-----------------------------------------------------------------------; 
In my ignorance I believe that the action tile(s) will be r41 - r49, however these are action tiles already for the 'Insert_Block_View'
This is where I run into problems :(


SteveN

Re: Can I have a choice of actions when selecting 'OK'?

#4
I've attached a copy of the lsp file, prior to the changes above.

This works in part.
The insertion of any block works as required, for s1 & s2. (INSERT_BLOCK_VIEW)
the new pipe (s7) works as required. (DRAW_PIPE_SHAPE)

However when inserting a block via s1 or s2 (fittings & flanges) the routine then continues with the 'pipe' function. Which is expected, see code below.
Since BOTH functions are called, however I am trying to achieve one or the other depending on the status of s7 (variable 'sel')

Code: Select all

(defun C:sln_piping ( / sel flg ftg fce sch clss fname )			;define function
  (setq
    OLDERR *ERROR*
    *ERROR* ERR
  ) ;_ end of setq
  (setq OS (getvar "OSMODE"))
  (setvar "OSMODE" 111)
  (DIALOG)
  (INSERT_BLOCK_VIEW)
  (DRAW_PIPE_SHAPE)	  
  (setvar "OSMODE" OS)
  (setq *ERROR* OLDERR) ; Restore old *error* handler
  (princ)
) ;end 
S.
Attachments
SLN_PIPING-REV 2-0-4-3-A1.zip
(5.98 KiB) Downloaded 234 times

Re: Can I have a choice of actions when selecting 'OK'?

#5
Hi,
Try to remove the line: (if (= NEWTILE "s7") (DRAW_PIPE_SHAPE) ) in function INSERT_BLOCK_VIEW.
And using this:

Code: Select all

(defun C:sln_piping ( / sel flg ftg fce sch clss fname )	;define function
  (setq
    OLDERR *ERROR*
    *ERROR* ERR
  ) ;_ end of setq
  (setq OS (getvar "OSMODE"))
  (setvar "OSMODE" 111)
  (DIALOG)
  (if (= NEWTILE "s7")
    (DRAW_PIPE_SHAPE)
    (INSERT_BLOCK_VIEW) )    	  
  (setvar "OSMODE" OS)
  (setq *ERROR* OLDERR) ; Restore old *error* handler
  (princ)
) ;end

or simple erase the line (DRAW_PIPE_SHAPE) in function C:sln_piping

Re: Can I have a choice of actions when selecting 'OK'?

#6
I have solved my problem :)

I changed this code:

Code: Select all

   
 (if (= NEWTILE "rb49")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;  end of if	
 ) ;  end INSERT_BLOCK_VIEW 
 
To this:

Code: Select all

(if 
	(and
	(= NEWTILE "rb49")
	(= sel "pipe_")
	) ;end and
		(DRAW_PIPE_SHAPE)
		(SET_BLOCK)
	) ;  end of if	
 ) ;  end INSERT_BLOCK_VIEW 
This now works as I wanted, just need to replicate on RB41 thro RB48.

Also deleted (DRAW_PIPE_SHAPE) from here:

Code: Select all

  (setq
    OLDERR *ERROR*
    *ERROR* ERR
  ) ;_ end of setq
  (setq OS (getvar "OSMODE"))
  (setvar "OSMODE" 111)
  (DIALOG)
  (INSERT_BLOCK_VIEW)
  (setvar "OSMODE" OS)
S.

Re: Can I have a choice of actions when selecting 'OK'?

#8
Well my elation was short lived :( As when I copied the new code for rb49 to rb41-48 the code failed!

This is what works:

Code: Select all

 (defun INSERT_BLOCK_VIEW ()
     (if (= NEWTILE "rb31")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb32")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb33")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb34")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb35")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb36")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb37")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb41")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb42")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb43")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb44")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb45")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb46")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb47")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb48")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
	(if 
		(and
		(= NEWTILE "rb49")
		(= sel "pipe_")
		) ;end and
			(DRAW_PIPE_SHAPE)
			(SET_BLOCK)
	) ;_ end of if
 ) ;end INSERT_BLOCK_VIEW
I can insert any of the fittings or flanges, and draw the selected pipe schedule/size.
(there is a minor issue with the pipe & ucs settings, for later)

However as soon as I repeat the modification for any of the other rb's the code fails
eg

Code: Select all

    (if (= NEWTILE "rb46")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    (if (= NEWTILE "rb47")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
  	(if 
		(and
		(= NEWTILE "rb48")
		(= sel "pipe_")
		) ;end and
			(DRAW_PIPE_SHAPE)
			(SET_BLOCK)
	) ;_ end of if
;    (if (= NEWTILE "rb48")
;    (SET_BLOCK)			;GOTO SET BLOCK
;  ) ;_ end of if
	(if 
		(and
		(= NEWTILE "rb49")
		(= sel "pipe_")
		) ;end and
			(DRAW_PIPE_SHAPE)
			(SET_BLOCK)
	) ;_ end of if
 ) ;end INSERT_BLOCK_VIEW
The failure:
In the first instance after selecting a fitting and selecting 'OK' the block appears on the cursor and can be inserted and the command terminates normally, well as I expect it too!!
In the second case, following the same process, after inserting the block the command does not terminate but waits for a second insertion point for the same block.

While writing this post I tried a third modification, this time to rb47:

Code: Select all

    (if (= NEWTILE "rb46")
    (SET_BLOCK)			;GOTO SET BLOCK
  ) ;_ end of if
    	(if 
		(and
		(= NEWTILE "rb47")
		(= sel "pipe_")
		) ;end and
			(DRAW_PIPE_SHAPE)
			(SET_BLOCK)
	) ;_ end of if
;    (if (= NEWTILE "rb47")
;    (SET_BLOCK)			;GOTO SET BLOCK
;  ) ;_ end of if
  	(if 
		(and
		(= NEWTILE "rb48")
		(= sel "pipe_")
		) ;end and
			(DRAW_PIPE_SHAPE)
			(SET_BLOCK)
	) ;_ end of if
;    (if (= NEWTILE "rb48")
;    (SET_BLOCK)			;GOTO SET BLOCK
;  ) ;_ end of if
	(if 
		(and
		(= NEWTILE "rb49")
		(= sel "pipe_")
		) ;end and
			(DRAW_PIPE_SHAPE)
			(SET_BLOCK)
	) ;_ end of if
 ) ;end INSERT_BLOCK_VIEW
With this change I now have 3 insertion points before the command terminates normally.

To my untrained/inexperienced eye, it's almost as if the ") ; end of if" is not being recognised??
Tried a forth and yes 4 insertion points.

SteveN.

Re: Can I have a choice of actions when selecting 'OK'?

#9
For anyone following this, a quick update.

I think I've solved it, well maybe :)

This is the code ATM:

Code: Select all

	(cond
	((and (= NEWTILE "rb41")(= sel "pipe_")) ;end and
	(DRAW_PIPE_SHAPE)
	)
	((and (= NEWTILE "rb42")(= sel "pipe_")) ;end and
	(DRAW_PIPE_SHAPE)
	)
	((and (= NEWTILE "rb43")(= sel "pipe_")) ;end and
	(DRAW_PIPE_SHAPE)
	)
	((and (= NEWTILE "rb44")(= sel "pipe_")) ;end and
	(DRAW_PIPE_SHAPE)
	)
	((and (= NEWTILE "rb45")(= sel "pipe_")) ;end and
	(DRAW_PIPE_SHAPE)
	)
	((and (= NEWTILE "rb46")(= sel "pipe_")) ;end and
	(DRAW_PIPE_SHAPE)
	)
	((and (= NEWTILE "rb47")(= sel "pipe_")) ;end and
	(DRAW_PIPE_SHAPE)
	)
	((and (= NEWTILE "rb48")(= sel "pipe_")) ;end and
	(DRAW_PIPE_SHAPE)
	)
	((and (= NEWTILE "rb49")(= sel "pipe_")) ;end and
	(DRAW_PIPE_SHAPE) 						 ;goto draw pipe shape
	)
	(t (SET_BLOCK))  						 ;goto set block
	) ;_ end of cond
Fitting & flanges are inserting as intended with the insert command NOT repeating. Also the pipe routine is working as intended.
(Note: this is in ICAD9.0, I will update the routine for ICAD10.)
edit:ICAD10 routine updated an working:)


S.