Luís Augusto Posted January 24, 2014 Author Posted January 24, 2014 Here is a suggestion. Prompt: Specify insertion point: Then specific ... Next Prompt: Specify insertion point: Then specific ... Next Until it runs out the possibilities ... Tharwat Hello, how are you? I bring good news. I believe that the function created by Lee Mac "Unique & Duplicate List Functions", solves the issue of generating a list of distinct names, required for program offer me the names for inserting blocks. Unfortunately I am not at all near the knowledge you have with autoLisp, otherwise I'd do the implementation of the code. That does not mean I'm not trying to, but if I do, will be more luck than skill. I was forced to interrupt my studies in that language in the past for serious personal reasons. Now I intend to go back to my studies and I do not stop until I become Self-Sufficient. Thank you for your help. A big hug. Regards, Luís Augusto. Quote
Tharwat Posted January 25, 2014 Posted January 25, 2014 All the best Luis . I hope that you would post the final codes here which I believe that many people would get the benefit of it Quote
Luís Augusto Posted January 27, 2014 Author Posted January 27, 2014 All the best Luis . I hope that you would post the final codes here which I believe that many people would get the benefit of it Surely I will post the code Tharwat. As I mentioned in post 3, there was a solution to the case but was not shared. I'll never do something like that. I'm not the author of the code, I'm just an apprentice who hopes to be helped again. Quote
Luís Augusto Posted January 27, 2014 Author Posted January 27, 2014 First I must thank the great friend Tharwat who devoted his free time to write this wonderful code. Thank you for always supporting me, I have great admiration for his work. I must also thank the great Lee Mac that on your site provides many functions and tutorials that greatly facilitate the learning of novice like me. I hope one day I can help others as I am helped here in this forum. I made minor changes to the program for it to work as my need. Thanks to everyone who participated in this post. Feel free to modify or improve the code. If want to test: Sample Conectors.zip POPULATE ATTRIBUTES.csv Remember:. The comma "," should be replaced by semicolons ";" depending on region. translated by google translate (defun c:Test (/ *error* Deconstruct_String right left con1 con2 xl ok o st l lst a b c d f fp bn p go vl name ch insertList) ;; ;; ;; Author : Tharwat Al Shoufi ;; ;; ;; (or doc (setq doc (vla-get-activedocument (vlax-get-acad-object)))) (defun *error* (u) (if ch (setvar 'CMDECHO ch) ) (princ "\n*Cancel*") ) (defun Deconstruct_String (st delimiter / p l) (while (setq p (vl-string-search delimiter st 0)) (setq l (cons (substr st 1 p) l) st (substr st (+ p 2) (strlen st)) ) ) (if st (setq l (cons st l)) ) (setq l (reverse l)) ) (if (setq xl (getfiled "Select the required Excel file :" (getvar 'DWGPREFIX) "csv" 16)) (progn (setq ok t ch (getvar 'CMDECHO) o (open xl "r") ) (setvar 'CMDECHO 0) (while (setq st (read-line o)) (setq l (cons (setq st (Deconstruct_String st ",")) l) ;The comma "," should be replaced by semicolons ";" depending on region. lst (cons (strcase (car st)) lst) ) ) (setq insertList (LM:Unique LST)) ;Modification 25/01/2014 (close o) ) (setq ok nil) ) (foreach blk insertList ;Modification 25/01/2014 (if (and ok (/= (setq bn blk) "") (if (member (setq bn (strcase bn)) lst) t (progn (alert "Block name is not included in the Excel file <!>") nil) ) (if (not (tblsearch "BLOCK" bn)) (if (setq fp (findfile (strcat bn ".dwg"))) (progn (command "_.-insert" fp nil) t) (progn (alert "Block Name is not found in Support Folder <!>") nil) ) t ) ) (progn (setvar 'CMDECHO ch) (vla-StartUndoMark doc) (setq p (getpoint (strcat "\n Specify insertion point: " blk))) ;Modification 25/01/2014 (setq vl (vla-insertblock (vla-get-block (vla-get-activelayout doc)) (vlax-3d-point p) bn 1.0 1.0 1.0 0.)) ;Modification 25/01/2014 (foreach x (vlax-invoke vl 'getattributes) (foreach tg l (if (and (eq (car tg) (strcase bn)) (eq (strcase (vla-get-tagstring x)) (cadr tg))) (vla-put-textstring x (caddr tg)) ) ) ) (vla-EndUndoMark doc) ) ) ) (princ "\nAll blocks were successfully inserted.") ;Modification 25/01/2014 (princ) ) (vl-load-com) ;; Unique - Lee Mac ;; Returns a list with duplicate elements removed. (defun LM:Unique ( l / x r ) (while l (setq x (car l) l (vl-remove x (cdr l)) r (cons x r) ) ) (reverse r) ) Quote
Tharwat Posted January 27, 2014 Posted January 27, 2014 Excellent , I am happy to help Luis and you are welcome anytime Quote
Recommended Posts
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.