Author Topic: How can I insert a variable into this statement  (Read 1162 times)

0 Members and 1 Guest are viewing this topic.

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
How can I insert a variable into this statement
« on: January 29, 2021, 03:55:36 AM »
Following on from my previous posts.
I am trying to create a 3D solid of a concentric reducer, taking the dimensions from a text file.

sample from the text file:
("24x16" "Con-Red_SCH_10_24_16-3D" "Con-Red.sld" 508.00 00.00 406.00 00.00 06.35 610.00 06.35 63.00 597.30 393.30)

Code: [Select]
  (setq    N1 (nth 3 SIZE_DIMS))
.
.
  (set_tile "n1" (rtos N1 2 2))

How can I insert a local variable into this statement ?
     (setq spt3 (strcat "0" "," "0" "," "200"))

I want to change the value 200 to the variable ERLENGTH.
I have tried:
(setq spt3 (strcat "0" "," "0" "," erlength))

The following code works with the value 200 in place. [ "200" ]

Code: [Select]
(defun DRAW_ER ( / spt1 spt2 ENT1 ENT2 ENT3 ENT4 ENT5 ENT6 EROD1 ERID1 EROD2 ERID2 ERLENGTH )
(setq EROD1 N6)
(setq ERID1 N9).
(setq EROD2 N3)
(setq ERID2 N10)
(setq ERLENGTH N1)
;
 (if (and (setq spt1 (getpoint "\nSpecify Start point of Reducer"))
          (setq spt2 (getpoint "\nSpecify Direction of Reducer"))
  (setq spt3 (strcat "0" "," "0" "," "200"))
     ) ;end of AND
;
;
      (progn
    (command "ucs" "ZA" spt1 spt2)
(command "circle" "0,0,0" "d" erod1) ;take OD from dim file
(setq ENT1 (entlast))
(command "circle" "0,0,0" "d" erid1) ;take ID from dim file
(setq ENT2 (entlast))
;
;
(command "circle" spt3 "d" erod2) ;take OD from dim file
(setq ENT3 (entlast))
(command "circle" spt3 "d" erid2) ;take ID from dim file
(setq ENT4 (entlast))
;
; ; setvar LOFTNORMALS 1  set this to 4
(setvar "LOFTNORMALS" 4) ; this works on command line
(command "loft" ENT1 "" ENT3 "" "")
(setq ENT5 (entlast))
(command "_loft" ENT2 "" ENT4 "" "")
(setq ENT6 (entlast))
;
;
  (command "subtract" ENT5 "" ENT6 "")
    (command "ucs" "_P")
(setvar "LOFTNORMALS" 1)
;
    ) ;_ end of progn
   )  ;_ end of IF
) ;end DRAW_ER

Any pointers or reading material where I can find my solution would be appreciated

Steve
There is no such  thing as a 'silly question' to those who do not know!

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How can I insert a variable into this statement
« Reply #1 on: January 29, 2021, 01:32:51 PM »
(setq ERLENGTH (rtos n1))

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: How can I insert a variable into this statement
« Reply #2 on: January 30, 2021, 05:55:14 AM »
(setq ERLENGTH (rtos n1))

Thanks Jeff
There is no such  thing as a 'silly question' to those who do not know!