Author Topic: Move dims and text to dim layer  (Read 3062 times)

0 Members and 1 Guest are viewing this topic.

Biscuits

  • Swamp Rat
  • Posts: 502
Move dims and text to dim layer
« on: July 27, 2007, 11:05:22 AM »
Using Acad2008 on XP

Anyone have a routine that would move all existing dims and text within a drawing to "dim" layer?

I work with an engineer who likes to draw everything on one layer.......argh!
Guess it could be worse!


Thanks

M-dub

  • Guest
Re: Move dims and text to dim layer
« Reply #1 on: July 27, 2007, 11:07:13 AM »
Just a stab in the dark, but could you use the command, 'Qselect' to select said objects and change them manually?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Move dims and text to dim layer
« Reply #2 on: July 27, 2007, 11:10:08 AM »
Something like
Code: [Select]
(vlax-for lo (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-Acad-Object)))
 (vlax-for obj (vla-get-Block lo)
  (if
   (or
    (vl-position (vla-get-ObjectName obj) '("AcDbText" "AcDbMText"))
    (vl-string-search "Dimension" (vla-get-ObjectName obj))
   )
   (vla-put-Layer obj "Dim")
  )
 )
)
Edit: Forgot a paren.
« Last Edit: July 27, 2007, 02:32:20 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Move dims and text to dim layer
« Reply #3 on: July 27, 2007, 12:05:47 PM »
optionally

click on the offending item(S)>>then right-click and chose Select Similar
then use the Layer Pull down on standard menu to move them to the correct layer,
or use the properties box to do same
Be your Best


Michael Farrell
http://primeservicesglobal.com/

Fatty

  • Guest
Re: Move dims and text to dim layer
« Reply #4 on: July 27, 2007, 01:02:57 PM »
I use similar on following one,
where command is accordingly layer
name on wich you want to offset the objects
I mean:
OF - offset
Dim - layer name
Easier to remember for me...
Hth

Code: [Select]
(defun C:OFDim (/)
(vl-load-com)
(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))   
(command "._-layer" "m" "dim" "c" "7" "dim" "")
(vlax-for layts (vla-get-layouts
                 (vla-get-activedocument
                     (vlax-get-acad-object)))
 (vlax-for obj (vla-get-block layts
  (if (wcmatch (vla-get-objectName obj) "*Text,*MText,*Dimension")
   (vla-put-Layer obj "Dim")
  )
 )
)
)
(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))   
(princ)
)
(princ "\n   >>> Type OFDIM to execute...")
(princ)

~'J'~

GDF

  • Water Moccasin
  • Posts: 2081
Re: Move dims and text to dim layer
« Reply #5 on: July 27, 2007, 02:13:51 PM »
Tim and Fatty


I get the following:
; error: bad argument type: VLA-OBJECT nil


Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Move dims and text to dim layer
« Reply #6 on: July 27, 2007, 02:33:08 PM »
Tim and Fatty


I get the following:
; error: bad argument type: VLA-OBJECT nil


Gary
It worked for me, once I put in the paren I forgot (updated code in first post).  I wonder if the layer is locked if you would get that message?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Move dims and text to dim layer
« Reply #7 on: July 27, 2007, 03:47:24 PM »
Tim

Strange, it's working now, and I did what you did.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Move dims and text to dim layer
« Reply #8 on: July 27, 2007, 04:19:44 PM »
Tim

Strange, it's working now, and I did what you did.

Gary
That is strange.  I have no idea why you would get that error, as there is no way to not get a vla-object in that code, when it is looking for one, at least that I can see.   :ugly:  If I'm wrong, please show me.  :-)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Move dims and text to dim layer
« Reply #9 on: July 30, 2007, 11:53:09 AM »
Thanks for all the help

I came up with this all by my lonesome

Nuthin purty..but it workt


Quote

(defun c:KLEINLAYER ()

 (command "-layer" "T" "*" "U" "*" "ON" "*" "")

 (command "-layer" "m" "CENTER" "c" "GREEN" "" "ltype" "CENTER2" "" "")
 (command "-layer" "m" "DWG" "c" "CYAN" "" "ltype" "CONTINUOUS" "" "")
 (command "-layer" "m" "SECTION" "c" "230" "" "ltype" "PHANTOM" "" "")
 (command "-layer" "m" "DIM" "c" "RED" "" "ltype" "CONTINUOUS" "" "")
 (command "-layer" "m" "HIDDEN" "c" "YELLOW" "" "ltype" "HIDDEN" "" "")
 (command "-layer" "m" "CORE" "c" "255" "" "ltype" "CONTINUOUS" "" "")
 (command "-layer" "S" "DWG" "")

(setq DIMset (ssget "X" '((0 . "DIMENSION"))))
(setq TEXTset (ssget "X" '((0 . "TEXT"))))
(setq MTEXTset (ssget "X" '((0 . "MTEXT"))))


(command ".chprop" DIMset "" "LA" "dim" "")
(command ".chprop" TEXTset "" "LA" "dim" "")
(command ".chprop" MTEXTset "" "LA" "dim" "")



(PRINC)
)