Multiplication and Text Separation

Multiplication and Text Separation

k005
Advisor Advisor
617 Views
8 Replies
Message 1 of 9

Multiplication and Text Separation

k005
Advisor
Advisor

 

Hi All !

 

2x62ø14/20 L=120
2x52ø14 L=120
2x82ø14/15/20 L=120
2x62ø14/9/14 L=120

We have data like text object

 

Question-1: Multiplying and updating the value in front of these articles.
Like 2x62 = 124ø14/20 L=120...

 

Question-2 : If this article is not two separate articles, separate them.

 

124ø14/20 L=120


Thanks in advance to the helper.

0 Likes
Accepted solutions (1)
618 Views
8 Replies
Replies (8)
Message 2 of 9

pbejse
Mentor
Mentor
(defun c:Anotherdemonstrationfork005 ( / selectionset increment entityData stringAssociationList 
				      	stringFromstringAssociationList positionOf_Ø MultiplyThis Multiplied)
  
(if  (setq selectionset (ssget "_:L" '((0 . "TEXT")(1 . "*#x#*ø#*"))))
  	(repeat (setq increment (sslength selectionset))
		(setq entityData  (entget (ssname selectionset (setq increment (1- increment)))))
	  	(setq stringAssociationList (assoc 1 entityData))
	  	(setq stringFromstringAssociationList (cdr stringAssociationList))

	  	(and
		  (setq positionOf_Ø (vl-string-position 216 (strcase stringFromstringAssociationList)))
	  	  (setq MultiplyThis (substr stringFromstringAssociationList 1 positionOf_Ø))
		  (setq Multiplied (eval (read (strcat "( *  " (vl-string-translate "X" " " (strcase MultiplyThis)) ")"))))
		  (entmod
		    (subst
		      (cons
			1
			(strcat	(itoa Multiplied)
				(substr	stringFromstringAssociationList
					(1+ positionOf_Ø)
				)
			)
		      )
		      stringAssociationList
		      entityData
		    )
		  )
		  )
	  )
  )
  (princ)
  )
Message 3 of 9

k005
Advisor
Advisor

 

Hello my friend,

Nice... well done. But question-2 is not included

0 Likes
Message 4 of 9

pbejse
Mentor
Mentor

@k005 wrote:

..But question-2 is not included

 

Question-2 : If this article is not two separate articles, separate them.

124ø14/20 L=120


You mean the string does not have a space " " between the number and "L=" or

Make it a separate Text object?

 


@k005 wrote:

Hello my friend, Nice... well done


Thank you for that @k005 

 

But here's a question for you,  did you try to code it yourself? With all the help you're getting. I think you owe it to the community to at least try writing it.   Are you even interested to learn programming?

 

  

 

0 Likes
Message 5 of 9

k005
Advisor
Advisor

 

...

Make a separate Text object?

...

 

 

Yes . a separate text object. only L=xxx this part.

I know programming partially...

 

* Two posts on the same axis.. There may be two spaces between them, for example..

 

or how much space there is in the original...

 

0 Likes
Message 6 of 9

pbejse
Mentor
Mentor

@k005 wrote:

..

Yes . a separate text object. only L=xxx this part.

I know programming partially...


If i give directions will you be able to put it together?

  • use Textbox  to identify the edge of the parsed string,
  • Entmake a new string on top of the original
  • Entmod the insertionpoint towards the edge + space
  • Change the string of the newly created Text object

 

 

 

0 Likes
Message 7 of 9

k005
Advisor
Advisor

 

No. I can't. Lisp seems too complicated to me. I know the main parts but that's all.

 

Thanks anyway mate.

0 Likes
Message 8 of 9

pbejse
Mentor
Mentor
Accepted solution

@k005 wrote:

No. I can't. Lisp seems too complicated to me. I know the main parts but that's all.

(defun c:AndYEtAnotherdemonstrationfork005 ( / selectionset increment entityData stringAssociationList  stringFromstringAssociationList
				      	positionOf_Ø MultiplyThis Multiplied Newstring entityDataForNewString positionOf_L
				      	FirstString EdgeOfFirstString MoveDistance TextInsertionPoint) 
  
(if  (setq selectionset (ssget "_:L" '((0 . "TEXT")(1 . "*#x#*ø#*"))))
  	(repeat (setq increment (sslength selectionset))
		(setq entityData  (entget (ssname selectionset (setq increment (1- increment)))))
	  	(setq stringAssociationList (assoc 1 entityData))
	  	(setq stringFromstringAssociationList (cdr stringAssociationList))

	  	(and
		  (setq positionOf_Ø (vl-string-position 216 (strcase stringFromstringAssociationList)))
	  	  (setq MultiplyThis (substr stringFromstringAssociationList 1 positionOf_Ø))
		  (setq Multiplied (eval (read (strcat "( *  " (vl-string-translate "X" " " (strcase MultiplyThis)) ")"))))
		  (setq Newstring (strcat	(itoa Multiplied)
					(substr	stringFromstringAssociationList
						(1+ positionOf_Ø)
					) 
				)
			      )		  
		  (setq entityData (entmod (subst (cons 1 Newstring)  stringAssociationList entityData)))
		  (setq entityDataForNewString (mapcar '(lambda (p)(assoc p entityData )) '(0 10 7 40 41)))
		  (setq positionOf_L (vl-string-search " L=" Newstring))
		  ;(setq SizeOfTheTextObject (textbox entityData))
		  (setq FirstString (substr Newstring 1 positionOf_L))
		  (setq EdgeOfFirstString (textbox  (cons (cons 1 (strcat FirstString "X")) (Cddr entityDataForNewString))))
		  (Entmakex (append  entityDataForNewString (list (Cons 1  FirstString))))
		  (setq MoveDistance (+ (caar EdgeOfFirstString) (caadr EdgeOfFirstString)))
		  (setq TextInsertionPoint (cdr (cadr entityDataForNewString)))
		  (setq entityData (entmod (subst (Cons 10  (cons (+ (car TextInsertionPoint) MoveDistance) (Cdr TextInsertionPoint)))
				        		(cadr entityDataForNewString)	entityData)))
		  (entmod (subst (cons 1 (substr Newstring (+ 2 positionOf_L)))
				 (assoc 1  entityData) entityData))
		  )
		  	  
	  )
  )
  (princ)
  )
Message 9 of 9

k005
Advisor
Advisor

 

 

Thank you very much, it's ok. 🤗

bless your hands.

0 Likes