- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Iam looking for a code for my project. In my drawing, I have multiple box available. In each box multiple texts are available. I need to make a list of that texts to paste in excel.
In picture you can see 3 boxes with different texts(number of boxes varies with my projects). Name of the box is not available in drawing.
My program will ask user "Provide 1st Box Name" (e.g. if user is putting box name as CAM1 then in excel in first column I need text as ***CAM1***)(in excel box name is displaying with prefix and suffix as ***)
After putting box name, program will ask user "Select text of CAM1", then user will select 1st text and then again program will ask user “Enter number” for 1st text which is required for number of times that text is required in excel. Then select next text and enter number of times need that second text, and so on. Those texts needs in list to paste in excl.
E.g. User is providing box name as CAM1.
Then selecting text ABC and entering 2 number.
Then selecting text ESC and entering number 3.
Then selecting text 435 and entering number 1.
Then selecting text ESC and entering number 4.
Then as a result I need a list text as ABC, ABC, ESC, ESC, ESC, 435, ESC, ESC, ESC, ESC which is below the ***CAM1***.
All the text which are selected in drawing should change their layer to "TXT_MISC" to understand that those are covered.
When I hit spacebar then program should ask "Provide 2nd Box name".
Then if user is putting name as NAT1 then ***NAT1*** will come below the box1 list.
In same way, user will select text AS3 from 2nd box and will enter number as 4.
Then user will select 2nd text ER12 and will enter number 3.
Then box 2 text will come below in same sequence like AS3, AS3, AS3, AS3, ER12, ER12, ER12 below text ***NAT1***. And all selected text layer will change in drawing.
Same way it will ask for box 3, box 4 and so on.
In last, when all boxes will finish, user will hit button L then excel list will be ready to paste in already opened excel sheet. User will go in Excel sheet and paste their list. List will look like as per attached picture.
Currently I am using below program but that gives me each text twice. Now I need text number of times as per user input.
(vl-load-com)
(defun c:TextList ( / tx ss d a htmlfile o c b n)
(defun *error* ( msg )
(if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
(princ (strcat "\nError: " msg))
)
(setq d nil)
(clip c)
(princ)
)
(setq lay "TXT_MISC")
(if (not (tblsearch "layer" lay))(command "_layer" "n" lay ""))
(setq n 1 c "")
(setq tx (getstring (strcat "\nProvide " (rtos n 2) " Box name :" )))
(while
(setq ss (ssget '((0 . "*TEXT"))))
(if ss
(repeat (setq i (sslength ss))
(setq o (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
(setq a (vlax-get-property o 'TextString))
(setq d (cons a d))
(vla-put-layer o lay)
)
)
(setq b (strcat "***" tx "***\n" (substr (apply 'strcat (mapcar '(lambda (x) (strcat "\n" x "\n" x)) d)) 2) "\n"))
(setq c (strcat c b))
(setq n (1+ n) d nil)
(setq tx (getstring (strcat "\nProvide " (rtos n 2) " Box name :" )))
)
(clip c)
(princ)
)
(defun clip (txt)
(terpri)(princ txt)
(vlax-invoke (vlax-get (vlax-get (setq htmlfile (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData) 'SetData "Text" txt)
(vlax-release-object htmlfile)
(princ)
)
(princ "\nType P2X")
(princ)
Please help. Thanks in advance!
Solved! Go to Solution.