Author Topic: top level xref in model space  (Read 9399 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: top level xref in model space
« Reply #30 on: November 06, 2007, 06:04:07 PM »
Good point. Fortunately our office policy is only one layout tab per drawing.
So is ours, but our consultants don't always follow our standard.   :-)
Tim

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

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: top level xref in model space
« Reply #31 on: November 06, 2007, 06:26:56 PM »
I had a minute, so here is the code to get the layers per model space.  Now don't look if you don't want to see the code yet.

Edit:  Updated code.  Wrong syntax on my part.






Code: [Select]
(defun LayListModelSpace (Doc / LayNameList BlkNameList GetBlockLayers)

(defun GetBlockLayers (BlkDefObj BlkCol)

(vlax-for obj BlkDefObj
(if (not (vl-position (vla-get-Layer obj) LayNameList))
(setq LayNameList (cons (vla-get-Layer obj) LayNameList))
)
(if (= (vla-get-ObjectName obj) "AcDbBlockReference")
(progn
(foreach att (append (vlax-invoke obj 'GetAttributes) (vlax-invoke obj 'GetConstantAttributes))
(if (not (vl-position (vla-get-Layer att) LayNameList))
(setq LayNameList (cons (vla-get-Layer att) LayNameList))
)
)
(if (not (vl-position (vla-get-Name obj) BlkNameList))
(progn
(GetBlockLayers
(vla-Item BlkCol (vla-get-Name obj))
BlkCol
)
(setq BlkNameList (cons (vla-get-Name obj) BlkNameList))
)
)
)
)
)
LayNameList
)

(GetBlockLayers (vla-get-ModelSpace Doc) (vla-get-Blocks Doc))
)
So for you, you would do something like
Code: [Select]
(setq LayList (LayListModelSpace dbxDoc))
since the routine wants a document object.  This will return a list of all the layer names, then you can do what you want with the list.
« Last Edit: November 06, 2007, 07:06:06 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.

Robert_s

  • Guest
Re: top level xref in model space
« Reply #32 on: November 06, 2007, 07:17:01 PM »
Tim,

Thank you. I really appreciate it. I'm learning a lot already.

Robert

T.Willey

  • Needs a day job
  • Posts: 5251
Re: top level xref in model space
« Reply #33 on: November 06, 2007, 07:23:19 PM »
You're welcome Robert.  I just hope you can follow the logic.  I know when I started to read people's code who have been doing it for a while, the logic was kind of lost on me.  Maybe you will pick it up faster than I did.
Tim

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

Please think about donating if this post helped you.