Jump to content

problems with generic to string


patjeacad

Recommended Posts

(defun C:dewall (/ )
	(setvar "CMDECHO" 0)
	(setq LAY (if  (not (TBLSEARCH "LAYER" "AL2100----_BUITENMUUR"))(COMMAND "LAYER" "M" "AL2100----_BUITENMUUR" "C" "9" "" "L" "CONTINUOUS" "" ""))) 
	(COMMAND "LAYER" "s" "AL2100----_BUITENMUUR" "" )
	(initget 1 "Nieuw Bestaand")
	(setq Tspmuur (getkword "\nSpouwmuur tekenen [Nieuw/Bestaand]: "))
	(PROGN
		(COND
			((= Tspmuur "Nieuw")   (Nieuw))
			((= Tspmuur "Bestaand")(Bestaand))
		);END COND
	)
)
(defun Nieuw (/ )
	(initget 1 "80 90 100 110 120 130 140 150 vrije-invoer")
	(setq Dbuitm (getkword "\nDikte Buitenmuur [80/90/100/110/120/130/140/150/vrije-invoer]: "))
	(PROGN
		(COND
			((= Dbuitm "80") (SETQ Dbuitm1  80))
			((= Dbuitm "90") (SETQ Dbuitm1  90))
			((= Dbuitm "100")(SETQ Dbuitm1  100))
			((= Dbuitm "110")(SETQ Dbuitm1  110))
			((= Dbuitm "120")(SETQ Dbuitm1  120))
			((= Dbuitm "130")(SETQ Dbuitm1  130))
			((= Dbuitm "140")(SETQ Dbuitm1  140))
			((= Dbuitm "150")(SETQ Dbuitm1  150))
			((= Dbuitm "vrije-invoer") (setq Dbuitm1 (getint "\nBreedte Buitenmuur in MM: ") Dbuitm (getstring Dbuitm1)))
		);END COND
	)
	(initget 1 "80 90 100 110 120 130 140 150 160 170 vrije-invoer") 
	(setq Dspouw (getkword "\nDikte spouw met isolatie [80/90/100/110/120/130/140/150/160/170/vrije-invoer]: "))
	(PROGN
		(COND
			((= Dspouw "80") (SETQ Dspouw1  80))
			((= Dspouw "90") (SETQ Dspouw1  90))
			((= Dspouw "100")(SETQ Dspouw1  100))
			((= Dspouw "110")(SETQ Dspouw1  110))
			((= Dspouw "120")(SETQ Dspouw1  120))
			((= Dspouw "130")(SETQ Dspouw1  130))
			((= Dspouw "140")(SETQ Dspouw1  140))
			((= Dspouw "150")(SETQ Dspouw1  150))
			((= Dspouw "160")(SETQ Dspouw1  160))
			((= Dspouw "170")(SETQ Dspouw1  170))
;			((= Dspouw "vrije-invoer") (setq Dspouw1 (getint "\nBreedte Spouw in MM: "))(setq Dspouw Dspouw1))
   );END COND
	)
	(initget 1 "80 90 100 110 120 130 140 150 vrije-invoer")
	(setq Dbinm (getkword "\nDikte binnenmuur [80/90/100/110/120/130/140/150/vrije-invoer]: "))
	(PROGN
		(COND
			((= Dbinm "80") (SETQ dbinm1  80))
			((= Dbinm "90") (SETQ dbinm1  90))
			((= Dbinm "100")(SETQ dbinm1  100))
			((= Dbinm "110")(SETQ dbinm1  110))
			((= Dbinm "120")(SETQ dbinm1  120))
			((= Dbinm "130")(SETQ dbinm1  130))
			((= Dbinm "140")(SETQ dbinm1  140))
			((= Dbinm "150")(SETQ dbinm1  150))
;			((= Dbinm "vrije-invoer") (setq dbinm1 (getkword "\nBreedte Binnenmuur in MM: "))(setq Dbinm Dbinm1))
		);END COND
	)  
	(setq MLINE_STYLE_NAME (strcat "Spouwmuur_" Dbuitm Dspouw dbinm))
	(if
		(not
			(dictadd
				(cdar (dictsearch (namedobjdict) "ACAD_MLINESTYLE"))
				MLINE_STYLE_NAME
				(entmakex
					(list '(0 . "MLINESTYLE")
					'(100 . "AcDbMlineStyle")
      
					(cons 2 MLINE_STYLE_NAME)
					'(70 . 0)
					'(3 . "")
					'(62 . 256)
					'(51 . 1.5708)
					'(52 . 1.5708)
					'(71 . 4)
					(cons 49  (+ Dbuitm1 ( / Dspouw1 2)))
					'(62 . 256)
					'(6 . "BYLAYER")
					(cons 49 ( / Dspouw1 2))
					'(62 . 1)
					'(6 . "BYLAYER")
					(cons 49  (* -1 ( / Dspouw1 2)))
					'(62 . 1)
					'(6 . "BYLAYER")
					(cons 49  (* -1 (+ DBINM1 ( / Dspouw1 2))))
					'(62 . 256)
					'(6 . "BYLAYER")
					)
				)
			)
		) 
		(alert "Impossible to create Mline Style\n It already exist")
	)
	(setvar 'cmlstyle MLINE_STYLE_NAME)	; make current.
	(command "mline" )					; hup, tekenen met zojuist aangemaakte MLine Style.
	(princ)
)
(Defun Bestaand(/)

	(command "mlstyle")					;mlstyle kiezen
	(command "Mline")					;tekenen spouwmuur.
)

I have a problem with the first "vrije_invoer" (user input). I can't convert a number to text. I have to put the input twice when i start the function in a dwawing. The result is correct, Mline_style_name gets the correct name,  and the mline is also correct.

Ofcource something is wrong. Can someone point me in the right direction?

Link to comment
Share on other sites

(setq Dspouw1 (itoa (getint "\nBreedte Spouw (mm) ")))

 

of (vl-princ-to-string (getint "..."))

  • Like 1
Link to comment
Share on other sites

Consider taking the direct integer input rather than converting a string to a number. Here's a simple example:
 

  ;; List of values to use
  (setq l '(80 90 100 110 120 130 140 150))
  (setq	dbuitm1
	 (cond
	   ;; If the user presses enter or the value does not exist in the list
	   ((car (member
		   (getint
		     "\nDikte Buitenmuur [80/90/100/110/120/130/140/150]:<Enter for user input> "
		   )
		   l
		 )
	    )
	   )
	   ;; Then prompt for a user input value here
	   ((getint "\nBreedte Buitenmuur in MM: "))
	 )
  )
  ;; Convert the numbers to strings and set your other variable to them
  ;; of course you have to make sure that 'dbuitm1 dspouw1 dbinm1' all exist
  (mapcar 'set '(dbuitm dspouw dbinm) (mapcar 'vl-princ-to-string (list dbuitm1 dspouw1 dbinm1)))

 

Edited by ronjonp
  • Like 1
  • Agree 1
Link to comment
Share on other sites

Your welcome to use this, just save Multi radio buttons.lsp to a support path.

 

(if (not AH:Butts)(load "Multi radio buttons.lsp")) ; loads the program if not loaded already
(setq Dbuitm (ah:butts 1 "V"   '("Choose " "80" "90" "100" "110" "120" "130" "140" "150" "vrije-invoer")))

image.png.fbf9f0d238d8f3d20637d1cb17649e61.png

Multi radio buttons.lsp

  • Like 1
Link to comment
Share on other sites

@ronjonp yes do have listbox code its just based on code that is already out there.

 

(if (not AHlstbox)(load "Listbox-AH.lsp"))
(setq ans (ahlstbox "Pick a linetype" lst 20 10))

 

It's just me I do not use initget. I know you make some great dcl's.

Edited by BIGAL
Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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