Jump to content

Recommended Posts

  • Replies 48
  • Created
  • Last Reply

Top Posters In This Topic

  • chulse

    27

  • Lee Mac

    21

  • Least

    1

Posted
Just in case anyone was watching...:D

 

And thanks again to LeeMac!! - this has been a massive workflow improvement for us and also a great learning experience for me. 8)

 

Hello Chulse,

 

out of interest could you post an example csv file and a drawing file showing the results?

 

Thanks

Posted
Hello Chulse,

 

out of interest could you post an example csv file and a drawing file showing the results?

 

Thanks

 

PM me your email and I'll send you a sample set - too large to post here...

Posted

Ok, Help please

 

I just found that this routine doesn't like the UCS to be anything but WORLD.

What would be the best way to handle this?

I think you could use a command call to set the UCS to world at the beginning of the code and use the same to return it to the previous UCS at the end?

Is there a better way?

Posted

Just a simple trans should do it:

 

;|
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
TCOT-TREE BLOCK INSERTER
READS FROM CSV FILE (TREE#, CANOPY RADIUS, CRD RADIUS, CRZ RADIUS) AND SETS ATTRIBUTE AND DYNAMIC PROPERTIES.
ALLOWS BREAK/RESUME
January 2010

CARY HULSE
With MAJOR help from Lee Mac (Lee McDonnell [leebob3@hotmail.com] (www.cadtutor.net/forum/member.php?u=16898)
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
|;

(defun c:tree (/ *error* StrBrk BNME DDEL DOC FILE LNAME NL OBJ OFILE PT SPC TAG UFLAG VALLST X CRZ CRD CANOPY)
 
 ;; by Lee Mac ~ 06.01.10
 
 (setq lname "LJ-PLNT-TREE") ;; Layer Name
 (setq  BNme "TCOT-TREE" ) ;; Block Name, MUST BE IN SUPPORT PATH AS DWG
 
 (vl-load-com)
 (setq DOC (vla-get-ActiveDocument (vlax-get-acad-object)))
   
 ;; --{  Error Handler Function  }--

 (defun *error* (msg)     
   (and ofile (close ofile))    
   (and uflag (vla-EndUndoMark doc))
   
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")        
       (princ (strcat "\n** Error: " msg " **")))    
   (princ))  
   
 ;; --{  StrBrk Function  }-- By Lee Mac

 (defun StrBrk (str chrc / pos lst)
   (while (setq pos (vl-string-position chrc str))
     (setq lst (cons (substr str 1 pos) lst)
           str (substr str (+ pos 2))))
   (reverse (cons str lst)))

 ;; CHECK FOR LAYER AND ADD IF NOT EXIST
 
 (or (tblsearch "LAYER" Lname)
     (vla-add (vla-get-layers doc) Lname))
     
 ;;***********MAIN FINCTIONS**************
 
 ;;COUNTER FUNCTION
 
 
 (if (and *lst* (not (initget "Start Continue")))
 (setq *lst* (if (= "Start" (getkword "\n[s]tart of File or [C]ontinue? <Continue> : ")) nil *lst*)))

(or *lst* (setq *rot* nil))

 
 (if (and (or (tblsearch "BLOCK" bNme)
              (setq bNme (findfile (strcat BNme ".dwg"))))           
          (or  *lst* (setq file (getfiled "Select Input File" (cond (*load_file*)  ("")) "csv;txt" 16))) 
          (or *ROT* (setq *ROT*  (cond ((getangle "\nEnter Block Rotation Angle <0.0> : ")) (0.0)))))
           
   (progn
     (setq uflag (not (vla-StartUndoMark doc))

           spc   (if (zerop (vla-get-activespace doc))
                   (if (= (vla-get-mspace doc) :vlax-true)
                     (vla-get-modelspace doc)
                     (vla-get-paperspace doc))
                   (vla-get-modelspace doc)))
     
     
     (if (not *lst*)
       (progn
         (setq dDel (if (eq ".CSV" (strcase (vl-filename-extension file))) 44 32)

               *block_file* bNme *load_file* file ofile (open file "r"))

         (while (setq nl (read-line ofile))
           (setq *lst* (cons (StrBrk nl dDel) *lst*)))

         (setq ofile (close ofile) *lst* (reverse *lst*))))
     
     
     (while (and (setq x  (car *lst*))
                 (setq pt (getpoint "\nSpecify Point for Block: ")))
       
   (if (vl-catch-all-error-p
             (setq OBJ
               (vl-catch-all-apply (function vla-InsertBlock)
                 (list spc (vlax-3D-point (trans pt 1 0)) bNme 1. 1. 1. *ROT*))))
                                   
         (princ "\n** Error Inserting Block **")
         (progn
           (vla-put-layer obj lname)

           (vla-put-TextString
             (car
               (vl-remove-if-not
                 (function
                   (lambda (x) (eq "TREE#" (strcase (vla-get-TagString x)))))
                 
                 (vlax-invoke Obj 'GetAttributes))) (car x))

                 
           (if (eq :vlax-true (vla-get-isDynamicBlock obj))
             (progn
             (setq ValLst (mapcar 'cons '("CANOPY RADIUS" "CRD RADIUS" "CRZ RADIUS")
                    (mapcar
                      (function
                        (lambda (i)
                          (if (equal 0.0 (distof i) 0.0001) "1" i)))
                      (list (cadr x) (caddr x) (cadddr x)))))

             
                   (foreach dAtt (vlax-safearray->list
                               (vlax-variant-value
                                 (vla-GetDynamicBlockProperties obj)))

                 (if (setq tag (assoc (strcase (vla-get-propertyName dAtt)) ValLst))
                   (vla-put-value dAtt
                     (vlax-make-variant (cdr tag)                        
                       (vlax-variant-type (vla-get-value dAtt))))))))))
 
         (princ (strcat "Tree# " (car x)))
       (setq *lst* (cdr *lst*)))

     (setq uFlag (vla-EndUndoMark doc))))

 (princ))

Posted
Just a simple trans should do it:

 

 

Excellent! One I got it in the right place it works perfect. Much easier than my way. Thanks.

Posted
On[c]e I got it in the right place it works perfect.

 

:huh: It should already be in the code above ... :unsure:

Posted
:huh: It should already be in the code above ... :unsure:

 

It was.

Instead of blindly copy/pasting - I wanted to try to understand what you did. When I added it to my copy, I forgot to remove the preceeding pt, so it didn't work until I figured that out. :oops:

 

Again, thanks for the education. :thumbsup:

Posted
It was.

Instead of blindly copy/pasting - I wanted to try to understand what you did. When I added it to my copy, I forgot to remove the preceeding pt, so it didn't work until I figured that out. :oops:

 

Again, thanks for the education. :thumbsup:

 

You're welcome :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...