chulse Posted May 7, 2010 Share Posted May 7, 2010 Is is possible to programmatically scale blocks based on a field in a CSV or from an attribute? I have used Lee Mac's Point Manager, (absolutely wonderful programm!!) but do not know how to set each one's scale based on a field in the CSV. Thanks in advance Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 7, 2010 Share Posted May 7, 2010 Oh good point - my program can only do a blanket insert with all at the same scale... Quote Link to comment Share on other sites More sharing options...
fixo Posted May 7, 2010 Share Posted May 7, 2010 Is is possible to programmatically scale blocks based on a field in a CSV or from an attribute? I have used Lee Mac's Point Manager, (absolutely wonderful programm!!) but do not know how to set each one's scale based on a field in the CSV. Thanks in advance Csv file should be in the following form: Block Name,X,Y,Z,Rotation,XScale,YScale ;;demo.lsp ; Convert value in degrees to radians (defun dtr (a) (* pi (/ a 180.0)) ) ;_ end of defun ;; by John Unden (defun ReadCSVFile(FileName / fileh line rtlist) (setq fileh (open FileName "r")) (while (setq line (read-line fileh)) (setq rtlist (cons (str2list line ",") rtlist)) ) (close fileh) (reverse rtlist) ) ;;;By John Uhden, as posted to the autodesk customization newsgroup 06 Feb 2003 (defun Str2List (str pat / i j n lst) (cond ((/= (type str)(type pat) 'STR)) ((= str pat)'("")) (T (setq i 0 n (strlen pat)) (while (setq j (vl-string-search pat str i)) (setq lst (cons (substr str (1+ i)(- j i)) lst) i (+ j n) ) ) (reverse (cons (substr str (1+ i)) lst)) ) ) ) (defun C:demo(/ bname input fname line ;|atdia atreq|; rot scale x xscale y yscale z) (setq acsp (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))) (setq fname (getfiled "Select The Block Data Input File" "" "csv" 0)) (setq input (ReadCSVFile fname)) (while (setq line (car input)) (setq bname (nth 0 line) x (atof (nth 1 line)) y (atof (nth 2 line)) z (atof (nth 3 line)) rot (dtr (atof (nth 4 line))) xscale (atof (nth 5 line)) yscale (atof (nth 6 line)) ) (vlax-invoke-method acsp 'InsertBlock (vlax-3d-point (list x y z)) bname xscale yscale 1.0 rot) (setq input (cdr input)) ) (princ) ) ~'J'~ Quote Link to comment Share on other sites More sharing options...
chulse Posted May 10, 2010 Author Share Posted May 10, 2010 Oh good point - my program can only do a blanket insert with all at the same scale... Lee, would it be possibe to add that functionality to you program? Quote Link to comment Share on other sites More sharing options...
chulse Posted May 10, 2010 Author Share Posted May 10, 2010 Csv file should be in the following form:Block Name,X,Y,Z,Rotation,XScale,YScale ... ~'J'~ Thanks! That gives me a great starting place, I need to have it import the block atributes also... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 10, 2010 Share Posted May 10, 2010 Lee, would it be possibe to add that functionality to you program? Perhaps - I'm pretty satisfied with the program as it is, so perhaps a custom code would be suitable for your needs in this case. Quote Link to comment Share on other sites More sharing options...
chulse Posted May 10, 2010 Author Share Posted May 10, 2010 Perhaps - I'm pretty satisfied with the program as it is, so perhaps a custom code would be suitable for your needs in this case. custom is perfect Is that something you could pull off for me, or at least gve me some hints? Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 10, 2010 Share Posted May 10, 2010 custom is perfect Is that something you could pull off for me, or at least gve me some hints? Thanks Has not Fixo provided sufficient code? Quote Link to comment Share on other sites More sharing options...
chulse Posted May 10, 2010 Author Share Posted May 10, 2010 Has not Fixo provided sufficient code? Unless I am missing it, it wouldn't populate the attributes. Could you point me to a way to add that functionality to it? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 12, 2010 Share Posted May 12, 2010 Pretty sure block creation using lisp help, has an extra bit about adding attributes. Its like step 2 of the wroked example. Quote Link to comment Share on other sites More sharing options...
thegreatkarthik67 Posted June 20, 2017 Share Posted June 20, 2017 Hi, I know its old thread but found very useful. Could you add attribute vale also for specified blocks. It would be great and will save me tons of time. I have to insert several blocks on x,y,z with some attributes. thanks MK Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 20, 2017 Share Posted June 20, 2017 (edited) Just open the csv with excel and use concatenate to make next line copy the column to the command line and all done. (command "-Insert" bnmame "x,y,z" 1 1 0 att1 att2) etc Edited June 21, 2017 by BIGAL Quote Link to comment Share on other sites More sharing options...
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.