Jump to content

Recommended Posts

Posted

I am trying to change the visibility of some blocks to another, but if there are blocks on two specific visibilities I don't want those to changes. i.e. All visibilities except UG Detail and AE Detail would switch to As-Built.

 

I've tried using other functions at different parts in the coding, but haven't gotten anything to work properly.

 

(defun c:ASB (/ BlockName ss)
 (setvar "cmdecho" 0)
 (vl-load-com)
 (setq BlockName (mapcar (function strcase)
                         '("call out box 1 (30)-sta"
               "call out box 2 (30)-sta"
               "call out box 3 (30)-sta"
               "call out box 4 (30)-sta"
               "call out box 5 (30)-sta"
               "call out box 6 (30)-sta"
               "call out box 7 (30)-sta")))

 (if (setq ss (ssget "_X"
                     (list '(0 . "INSERT")
                           (cons 2
                                 (apply (function strcat)
                                        (cons "`*U*,"
                                              (mapcar (function (lambda (s) (strcat s ",")))
                                                      BlockName)))))))
   (progn
     (vlax-for x (setq ss (vla-get-activeselectionset
                            (cond (*AcadDoc*)
                                  ((setq *AcadDoc* (vla-get-activedocument
                                                     (vlax-get-acad-object)))))))
       (if (and (vl-position
                  (strcase (vlax-get-property
                             x
                             (if (vlax-property-available-p x 'EffectiveName)
                               'EffectiveName
                               'Name)))
                  BlockName)
                (eq (vla-get-isDynamicBlock x) :vlax-true))
         (vl-some (function (lambda (p)
                              (if (eq (vlax-get-property p "PropertyName") "Placement Type")
                (not (vl-catch-all-error-p
                                       (vl-catch-all-apply
                                         (function vlax-put-property)
                                         (list p "Value" "As-Built")))))))
                  (vlax-invoke x 'GetDynamicBlockProperties))))
     (vla-delete ss)))
 (setvar "cmdecho" 1)
 (princ))

Posted
I am trying to change the visibility of some blocks to another, but if there are blocks on two specific visibilities I don't want those to changes. i.e. All visibilities except UG Detail and AE Detail would switch to As-Built.

 

You want this done globally? (as your codes suggest)

 

Most of the time, requests are for general use. (generic)

I personally write codes for specific tasks and for specific objects, as much as possible i would try to write it for general usage.

 

It would help others to undertand better if you have the actual block posted here. its not a requirement though but then again it would speed your chances for a quick response and a solution.

Posted

Yeah, I'd like this done globally, sorry for any confusion. I thought I had uploaded the block, here it is...

Call Out Box.dwg

Posted

Alright... tommorrow we'll have a look see :wink:

Posted

For the code to work (1st post)

visibilty "As-Built" should be defined. I dont see that on the block you posted, modify your block to include that value and adjust the lookup parameter as well.

After you're done with that then we'll take care of the UG Detail and AE Detail exclusion .

 

BTW. are all blocks listed on your list (BlockName) behaves the same way as the one posted?

Posted

Sorry, grabbed a block from the previous version. Here is the proper one. All of the blocks behave the same way, but the list is bigger than that as it includes other scales as well.

Call Out Box.dwg

Posted
 
(defun c:ASB (/ BlockName ss)
 (setvar "cmdecho" 0)
 (vl-load-com)
 (setq BlockName (mapcar (function strcase)
                         '("call out box 1 (30)-sta"
               "call out box 2 (30)-sta"
               "call out box 3 (30)-sta"
               "call out box 4 (30)-sta"
               "call out box 5 (30)-sta"
               "call out box 6 (30)-sta"
               "call out box 7 (30)-sta")))
 (if (setq ss (ssget "_X"
                     (list '(0 . "INSERT")
                           (cons 2
                                 (apply (function strcat)
                                        (cons "`*U*,"
                                              (mapcar (function (lambda (s) (strcat s ",")))
                                                      BlockName)))))))
   (progn
     (vlax-for x (setq ss (vla-get-activeselectionset
                            (cond (*AcadDoc*)
                                  ((setq *AcadDoc* (vla-get-activedocument
                                                     (vlax-get-acad-object)))))))
       (if (and (vl-position
                  (strcase (vlax-get-property
                             x
                             (if (vlax-property-available-p x 'EffectiveName)
                               'EffectiveName
                               'Name)))
                  BlockName)
                (eq (vla-get-isDynamicBlock x) :vlax-true))
         (vl-some (function (lambda (p)
                              (if (and
                                  (eq (vlax-get-property p "PropertyName") "Placement Type")
                                [color=blue]  (not
        (wcmatch (variant-value (vlax-get-property p  'Value)) "UG*,AE*")))
[/color]                 (not (vl-catch-all-error-p
                                       (vl-catch-all-apply
                                         (function vlax-put-property)
                                         (list p "Value" "As-Built")))))))
                  (vlax-invoke x 'GetDynamicBlockProperties))))
     (vla-delete ss)))
 (setvar "cmdecho" 1)
 (princ))

Posted

Awesome! Thanks, I first saw the wcmatch function yesterday looking through some other coding here.

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...