Jump to content

Recommended Posts

Posted

so to freeze the layers that are now created, I just added the following code within the vlax-for l function

(vl-catch-all-apply 'vla-put-Freeze (list l :vlax-true))

  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    16

  • ccowgill

    13

  • alanjt

    2

Popular Days

Top Posters In This Topic

Posted

That may work - I've never tested to see if a layer status is retained following the CopyObjects operation.

Posted

it appears to, as I have tested it and it does freeze the newly created layers. On the [cr] and snvalid, I checked and it is not allowing a space at the beginning of a string, so I'll just resolve it by adding the space to the strcat:

 

Command: (snvalid " test")

nil

 

Command: (snvalid "to test")

T

Posted

Yes, I meant with the snvalid removed as well - see the code in the original post.

Posted

Ok, I got it. thanks again for all your help.

Posted

What about something like this?

 

(defun c:CopyToLayerWithSuffix (/ suffix ss)
 ;; Alan J. Thompson, 12.02.10

 (vl-load-com)

 (setq suffix (getstring T "\nSpecify layer suffix: "))

 (if (setq ss (ssget "_:L"))
   ((lambda (layers match / name layer new item)
      (vlax-for x (setq ss (vla-get-activeselectionset *AcadDoc*))
        (or (wcmatch (strcase (setq layer (vla-get-layer x))) match)
            (vla-put-layer
              (vla-copy x)
              (cond
                ((cdr (assoc 2 (tblsearch "LAYER" (setq name (strcat layer suffix))))))
                ((setq new  (vla-add layers name)
                       item (vla-item layers layer)
                 )
                 (foreach p '(Color Description Linetype Lineweight Material PlotStyleName TrueColor)
                   (vl-catch-all-apply
                     (function vlax-put-property)
                     (list new p (vlax-get-property item p))
                   )
                 )
                 name
                )
              )
            )
        )
      )
      (vla-delete ss)
    )
     (vla-get-layers
       (cond (*AcadDoc*)
             ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
       )
     )
     (strcat "*" suffix)
   )
 )
 (princ)
)

Posted

Nice one Alan - that was the way I was initially suggesting - I just didn't want the legwork of copying all the layer properties :P

Posted
Nice one Alan - that was the way I was initially suggesting - I just didn't want the legwork of copying all the layer properties :P

Thanks. I was thinking the same thing about ODBX.

Posted

well that would put it back in line, coding style-wise, with the layer/layerstate program you helped me out with a few months ago at AUGI. Although looking at Lee's coding, it looks very similar to what was done in the original LAFreeze program I was trying to modify. Perhaps Lee wrote it originally?

Posted
well that would put it back in line, coding style-wise, with the layer/layerstate program you helped me out with a few months ago at AUGI. Although looking at Lee's coding, it looks very similar to what was done in the original LAFreeze program I was trying to modify. Perhaps Lee wrote it originally?

 

I'm afraid I've written too much code to remember :ouch: I'd have to see the code...

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