Jump to content

CHANGE TEXT names on drawing with ANOTHER


ojacomarket

Recommended Posts

Dear friends,

Another issue of mine. I got some texts, representing level above Sea Level on my drawing, but they are in old system, I got a constant that I should add to every TEXT object on that drawing. 

 

Some pics of what I suppose to do, and I actually don't understand, why my code doesn't work..

 

(defun c:EH2000korg ()


	(setq set_1 (ssget "x" (list (cons 0 "TEXT") (cons 7 "ITALIC") (cons 8 "korgus-EH2000")))) ;create selection set of specified objects
	
    
(setq 1_1 (- 0 1))
		
        
	(setq s_list_1 (list))
			
            
(setq s_list_2 (list))
			
            
	(setq s_list_3 (list))
    
    
   (setq s_list_12 (list))


(repeat (sslength set_1) ;start repeat
				
                
	(setq 1_1 (1+ 1_1))
			
            
(setq ss_set_1 (entget (ssname set_1 1_1)))
				
                
	(foreach xxx ss_set_1 (progn (setq num111 (car xxx)) (setq koord111 (cdr xxx)) (if (= num111 10) (setq s_list_3 (append s_list_3 (list koord111))))))
	
    
(foreach xx ss_set_1 (progn (setq num11 (car xx)) (setq angle11 (cdr xx)) (if (= num11 50) (setq s_list_2 (append s_list_2 (list angle11))))))
	
    
	(foreach x ss_set_1 (progn (setq num1 (car x)) (setq text1 (cdr x)) (if (= num1 1) (setq s_list_1 (append s_list_1 (list (strcat " " (rtos (+ 0.23 (atof text1))))))))))
	
    
	(foreach xxxx ss_set_1 (progn (setq num12 (car xxxx)) (setq text12 (cdr xxxx)) (if (= num12 1) (setq s_list_12 (append s_list_12 (list text12))))))
	
    
(setq new_coords (subst (nth 1_1 s_list_1) (nth 1_1 s_list_12) s_list_12))


) ;end repeat
) ;end defun

 

aft.png

tt.png

Edited by ojacomarket
Link to comment
Share on other sites

40 minutes ago, eldon said:

It looks to me as if your "rtos" function is being affected by the system variable DIMZIN

This step is executed by programm clearly, the problem is that code doesn;t change old text values to the new ones, as shown on pic I pinned. below are old values and above are new ones..

Edited by ojacomarket
Link to comment
Share on other sites

I am presuming that your problem is that the new value of '41.70' is only shown as '41.7'. That is to say the trailing zero has been left off.

 

If you investigate the working of DIMZIN and its unintended effect on 'rtos' and 'angtos', you will see what I mean.

 

Just to test my theory, see what DIMZIN is set to now, change it to 1, run your lisp and see what happens.

 

If your lisp now runs as it should, then you can edit your lisp to run perfectly.

Link to comment
Share on other sites

So... you got the insertion point, rotation, and text... where all you need is the text. Why would you need to gather all the other data?

 

Plus, you only set your results in the "new_coords" variable, you didn't actually modified the entity itself. You should look at the entmod or vla-put-TextString function.

 

Also, have a look at the assoc function, it will save you lots of trouble and lines. Below should achieve what you want:

 

(defun c:EH2000korg ( / 1_1 const ent set_1 text1)
  (setq const (cond ((getreal "\nSpecify constant to add <0.23>: ")) (0.23)))
  (if (setq set_1 (ssget "x" '((0 . "TEXT") (7 . "ITALIC") (8 . "korgus-EH2000"))))
    (repeat (setq 1_1 (sslength set_1))
      (setq ent (ssname set_1 (setq 1_1 (1- 1_1)))
	    text1 (cdr (assoc 1 (entget ent)))
	    )
      (entmod
	(subst
	  (cons 1 (strcat " " (rtos (+ const (atof text1)) 2 2)))
	  (assoc 1 (entget ent))
	  (entget ent)
	  )
	)
      )
    )
  (princ)
  )

 

Edited by Jonathan Handojo
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

19 minutes ago, eldon said:

I am presuming that your problem is that the new value of '41.70' is only shown as '41.7'. That is to say the trailing zero has been left off.

 

If you investigate the working of DIMZIN and its unintended effect on 'rtos' and 'angtos', you will see what I mean.

 

Just to test my theory, see what DIMZIN is set to now, change it to 1, run your lisp and see what happens.

 

If your lisp now runs as it should, then you can edit your lisp to run perfectly.

(defun c:EH2000korg ()

	(setq set_1 (ssget "x" (list (cons 0 "TEXT") (cons 7 "ITALIC") (cons 8 "korgus-EH2000"))))
	
		(setq 1_1 (- 0 1))
		
			(setq s_list_1 (list))
			
				(setq s_list_2 (list))
				
			(setq s_list_3 (list))
            
		 (setq s_list_12 (list))
	 
	 (setq old_dim (getvar "dimzin"))
     
(setq new_dim (setvar "dimzin" 1))

					(repeat (sslength set_1)
				
						(setq 1_1 (1+ 1_1))
			
							(setq ss_set_1 (entget (ssname set_1 1_1)))
							
								(foreach xxx ss_set_1 (progn (setq num111 (car xxx)) (setq koord111 (cdr xxx)) (if (= num111 10) (setq s_list_3 (append s_list_3 (list koord111))))))
							
									(foreach xx ss_set_1 (progn (setq num11 (car xx)) (setq angle11 (cdr xx)) (if (= num11 50) (setq s_list_2 (append s_list_2 (list angle11))))))
					
										(foreach x ss_set_1 (progn (setq num1 (car x)) (setq text1 (cdr x)) (if (= num1 1) (setq s_list_1 (append s_list_1 (list (strcat " " (rtos (+ 0.23 (atof text1))))))))))
								
									(foreach xxxx ss_set_1 (progn (setq num12 (car xxxx)) (setq text12 (cdr xxxx)) (if (= num12 1) (setq s_list_12 (append s_list_12 (list text12))))))
								
								(setq new_make (entmake (list (cons 0 "TEXT") (cons 1 (nth 1_1 s_list_1)) (cons 7 "ITALIC") (cons 8 "korgus-EH2000") (cons 10 (nth 1_1 s_list_3)) (cons 50 (nth 1_1 s_list_2)))))
								
							
							)
						
                        (setq old_dim (setvar "dimzin" old_dim))
                        
					)
                        
				)

Doesn't change...

I for real, have no Idea why the code doesn;t make new text objects with new elevations... as I made entmake with old coordinates and rotations... but nothing happend

Link to comment
Share on other sites

15 minutes ago, Jonathan Handojo said:

So... you got the insertion point, rotation, and text... where all you need is the text. Why would you need to gather all the other data?

 

Plus, you only set your results in the "new_coords" variable, you didn't actually modified the entity itself. You should look at the entmod or vla-put-TextString function.

 

Also, have a look at the assoc function, it will save you lots of trouble and lines. Below should achieve what you want:

 


(defun c:EH2000korg ( / 1_1 const ent set_1 text1)
  (setq const (cond ((getreal "\nSpecify constant to add <0.23>: ")) (0.23)))
  (if (setq set_1 (ssget "x" '((0 . "TEXT") (7 . "ITALIC") (8 . "korgus-EH2000"))))
    (repeat (setq 1_1 (sslength set_1))
      (setq ent (ssname set_1 (setq 1_1 (1- 1_1)))
	    text1 (cdr (assoc 1 (entget ent)))
	    )
      (entmod
	(subst
	  (cons 1 (strcat " " (rtos (+ const (atof text1)) 2 2)))
	  (assoc 1 (entget ent))
	  (entget ent)
	  )
	)
      )
    )
  (princ)
  )

 

Thank you very much! That result is what I needed. For sure I have forgotten about entmod func.

Code got excellent result!

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