After Attribute textstyle change, routine don´t work correctly...

After Attribute textstyle change, routine don´t work correctly...

C.Utzinger
Collaborator Collaborator
993 Views
8 Replies
Message 1 of 9

After Attribute textstyle change, routine don´t work correctly...

C.Utzinger
Collaborator
Collaborator

HI

 

I have severall problems with the attached LSP and the blocks.

 

I changed only the textstyle of the attribute from "simplex" to "Arial Narrow" and now the routine don't works correctly.

 

Why is that?

 

 

Please help...

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

dmfrazier
Advisor
Advisor

I'm going to go for the "low hanging fruit" here and suggest (since we're dealing with attributes in a block) that perhaps running AttSync on the block will resolve the issue. (Worth a shot?)

0 Likes
Message 3 of 9

C.Utzinger
Collaborator
Collaborator

No Smiley Frustrated

 

 

0 Likes
Message 4 of 9

C.Utzinger
Collaborator
Collaborator

For example with the attached dwgs the following part of the code only works with the block attributes with simplex style not with Arial Narrow.

 

Command line: ; Fehler: Fehlerhafter Argumentwert: Nicht negativ: -1

 

(defun NeuPosition (/ _split _padZero ss i e attVal_collection Startnum
                Low_Num High_Num  Preifxformat sstyp)
      
(defun _padZero (num md)
      (while (< (strlen num) md)
		(setq num (strcat "0" num))
	)
      num
      )
      
(defun _split (lst i / numbers)
	(while (< 46  (setq n (nth (setq i (1- i)) lst)) 58)
			(setq numbers (cons n  numbers)))
      	(if (and numbers
                 (setq str (vl-list->string lst)))
		 (list (substr str 1 (1+ i)) (vl-list->string numbers))))

(initget "Alle Wählen")
(setq sstyp (getkword "\nAuswahl Koordinatenpunkte [Alle/ Wählen] <Alle>:"))

(and (setq ss (if (= sstyp "Wählen")(ssget "_:L" 
                                           '((0 . "INSERT")
                                            (66 . 1)
                                            (2 . "SPI-Koordinatenpunkt")))
     			            (ssget "_X" 
                                           '((0 . "INSERT")
                                            (66 . 1)
                                            (2 . "SPI-Koordinatenpunkt")))))

     (repeat (setq i (sslength ss))
	  (setq e (vlax-ename->vla-object  (ssname ss (setq i (1- i)))))
          (setq attval (car (mapcar (function (lambda (at / num)                         
					 (list ( _split  (vl-string->list
						(setq str (vla-get-textstring at))) (strlen str)) at )))
                                  	 (vlax-invoke e 'Getattributes))))
           
	  	(if (car attval) (setq attVal_collection (cons attval  attVal_collection)))
           	attVal_collection
	  )
    	(setq attVal_collection 				 
	       (vl-sort attVal_collection
					 '(lambda (a b) (< (distof (cadar a))
							   (distof (cadar b))))))

	(setq Low_Num 	(cadar (car attVal_collection)))
        (setq High_Num  (cadar (last attVal_collection)))
	(setq Preifxformat (if (< (strlen Low_Num) (strlen High_Num))
                                       	 0 (strlen Low_Num)))
     
	(setq startNum
	  (cond
	    ((getint  (strcat "\nStartnummer angeben <"
	          (itoa (setq startNum (atoi Low_Num)))
	          ">: " )))
	    ( startNum )
	  )
	)
	    (Foreach itm attVal_collection
	      (vla-put-textstring (Cadr itm)
	      (strcat (Caar itm)
                    (if (zerop  Preifxformat) (itoa startNum)
                    	(_padZero (itoa startNum) Preifxformat ))))
	      (setq startNum (1+ startNum))
	    )
	)
   (command "_.regen")
); end of defun
0 Likes
Message 5 of 9

C.Utzinger
Collaborator
Collaborator

With Attribute values like:

 

EG-001, EG-002 etc. everything works!

 

Only when there are only numbers, then it is not working.

 

Smiley Frustrated

0 Likes
Message 6 of 9

dmfrazier
Advisor
Advisor

This suggests that there is a need to convert a value (or some values) from numerical data type to string at some point(s) in the code.

0 Likes
Message 7 of 9

C.Utzinger
Collaborator
Collaborator

I have found one problem i don't know how to solve.

 

It is the text width. With multilinetext, and text width 0.7 it works, because the value of the text is something like \W0.7000;001.

With width value 1, the value is only 001.

 

Any idea? The codes are to much for me...

0 Likes
Message 8 of 9

C.Utzinger
Collaborator
Collaborator
Accepted solution

I just had to modifiy this part and know it works!

 

(defun _split (lst i / numbers)
	(while (< 46  (setq n (if (/= i 0)(nth (setq i (1- i)) lst) (setq i (1- i)))) 58)   
			(setq numbers (cons n  numbers)))
      	(if (and numbers
                 (setq str (vl-list->string lst)))
		 (list (substr str 1 (1+ i)) (vl-list->string numbers))))

 

Kind regards

0 Likes
Message 9 of 9

dmfrazier
Advisor
Advisor

Yes, mtext formatting codes do add extra challenges, don't they.

 

Glad you were able to figure it out.

0 Likes