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

0 Members and 1 Guest are viewing this topic.

Robert_s

  • Guest
top level xref in model space
« on: November 05, 2007, 10:43:08 AM »
Hello,

With Lisp/Vlisp is there a way to get the top most level/Parent xref in "Model space". We
usually only have one xref in model space (but is nested) without selecting the xref? (We
also only have one xref in Paper space and that would be the Titble block).

I just need to know the parent one. I dont need to know the nested ones.

Thanks,
Robert

T.Willey

  • Needs a day job
  • Posts: 5251
Re: top level xref in model space
« Reply #1 on: November 05, 2007, 11:00:08 AM »
Use 'ssget' to select all the blocks in model space, then test their block definition to see if they are xrefs.  Or you could step through the block collection (table) and see if the item is a block, and if so if it is inserted into model space.
Tim

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

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: top level xref in model space
« Reply #2 on: November 05, 2007, 11:07:01 AM »
Give this a whirl:

Code: [Select]
(defun gettoplevelmsxrefs (/ ss lst)
  (if (setq ss (ssget "x" '((0 . "INSERT") (410 . "Model"))))
    (progn
      (setq ss (mapcar 'cadr (ssnamex ss)))
      (mapcar '(lambda (x)
(if (vlax-property-available-p
       (vlax-ename->vla-object x)
       'Path
     )
   (setq lst (cons x lst))
)
       )
      ss
      )
      lst
    )
  )
)
(gettoplevelmsxrefs)
« Last Edit: November 05, 2007, 11:13:21 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Robert_s

  • Guest
Re: top level xref in model space
« Reply #3 on: November 05, 2007, 11:19:28 AM »
Hello again,

Thank you guys. But I think I forgot to mention I am new with lisp/vlisp.
When I loaded the code it returned...

(<Entity name: 79dd60a8> <Entity name: 79dd60a8> <Entity name: 79dd60a8>)

I was hoping to see the name and path of the xref. How do I extract my desired
information..name & path?

Thanks again,
Roberrt

ronjonp

  • Needs a day job
  • Posts: 7531
Re: top level xref in model space
« Reply #4 on: November 05, 2007, 11:27:08 AM »
Try this Robert:

Code: [Select]
(defun gettoplevelmsxrefs (/ ss lst)
  (if (setq ss (ssget "x" '((0 . "INSERT") (410 . "Model"))))
    (progn
      (setq ss (mapcar 'cadr (ssnamex ss)))
      (mapcar '(lambda (x)
(if (vlax-property-available-p
       (vlax-ename->vla-object x)
       'Path
     )
   (setq lst (cons (vlax-ename->vla-object x) lst))
)
       )
      ss
      )
      (if lst
(mapcar
  '(lambda (x)
     (princ (strcat "\nName: " (vla-get-name x) " - Path: " (vla-get-path x))
     )
   )
  lst
)
      )
      lst
    )
  )
)
(gettoplevelmsxrefs)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Robert_s

  • Guest
Re: top level xref in model space
« Reply #5 on: November 05, 2007, 11:36:12 AM »
Hi,

Almost there! Can you please make it return in a list form?

For example.
if one xref.... ("p:\\projects\\xref\\plan1.dwg")
if two xrefs ..("p:\\projects\\xref\\plan1.dwg" "p:\\projects\\xref\\plan2.dwg")

Thanks
Robert

ronjonp

  • Needs a day job
  • Posts: 7531
Re: top level xref in model space
« Reply #6 on: November 05, 2007, 11:41:46 AM »
Hi,

Almost there! Can you please make it return in a list form?

For example.
if one xref.... ("p:\\projects\\xref\\plan1.dwg")
if two xrefs ..("p:\\projects\\xref\\plan1.dwg" "p:\\projects\\xref\\plan2.dwg")

Thanks
Robert

This will return a list like this ("path1" "path2" "path3").... What are you going to do with this list?

Code: [Select]
(defun gettoplevelmsxrefs (/ ss lst)
  (if (setq ss (ssget "x" '((0 . "INSERT") (410 . "Model"))))
    (progn
      (setq ss (mapcar 'cadr (ssnamex ss)))
      (mapcar '(lambda (x)
(if (vlax-property-available-p
       (vlax-ename->vla-object x)
       'Path
     )
   (setq lst
  (cons (vla-get-path (vlax-ename->vla-object x)) lst)
   )
)
       )
      ss
      )
      lst
    )
  )
)
(gettoplevelmsxrefs)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Robert_s

  • Guest
Re: top level xref in model space
« Reply #7 on: November 05, 2007, 12:07:57 PM »
Hi,

Yes! yes! yes!. This is exactly what I needed!

Like I said I am new with lisp/vlisp. But I want to write a code using
ObjectDbx.  I want to update my Plot sheets layers.

When users in my office work on drawings that are being xref to plot
sheets. They freeze layers and sometimes change layer colors. But
when they open up their respective plot sheet it does not update the
layers. And we get into a lot of trouble with each submission. Cause
we only open the plot sheet when we are ready to plot.

When you open a plot sheet. Without the user knowing...
1. I want to know the parent xref/s in model space.
2. Open that xref/s drawing with ObjectDbx and collect the layer settings.
3. Update the layer settings of the opened plot sheet to reflect/update/match
    with the xref drawing.

Of course if you feel like coding it yourself I wont stop you (Hint..hint). 

Thank you very much!
Robert,






T.Willey

  • Needs a day job
  • Posts: 5251
Re: top level xref in model space
« Reply #8 on: November 05, 2007, 12:11:58 PM »
3. Update the layer settings of the opened plot sheet to reflect/update/match
    with the xref drawing.
See if the routine here is something that will help you.
Tim

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

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: top level xref in model space
« Reply #9 on: November 05, 2007, 12:35:26 PM »
Wouldn't setting VISRETAIN to 0 do what you want without code?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

T.Willey

  • Needs a day job
  • Posts: 5251
Re: top level xref in model space
« Reply #10 on: November 05, 2007, 01:08:03 PM »
Wouldn't setting VISRETAIN to 0 do what you want without code?
But that will turn on and freeze the layers per the xref also.  Just an FYI.
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 #11 on: November 05, 2007, 01:09:09 PM »
Hi Tim,

I tried the code "SetOrigLayerProps" on Autocad 2006 & Autocad 2008.
In 2008 I changed the line.. (if (< (atoi (setq oVer (substr (getvar "acadver") 1 2))) 16)..from 16 to 17.

I tried using the code on the plot sheet and it gave me this error:..

Single layer, or All layers <S>:
Select object within Xref to copy back original layer properties: error:
Automation Error. Key not found

Then it made the parent xref a read only file. But you what. This can serve as a sample coding for me.
Thanks for the link.

And Ron (sorry, did I get your first name right?), setting visretain to 0 will not work. The parent xref also has
parent * nested xrefs. The Plot sheet will reflect the 2nd level set of xrefs (the ones being xref into the parent xref).
What I am trying to say is that with visretain set to 0, Plot sheet will update to layer settings of the "xrefs"
of parent drawing NOT the layer settings of "parent" drawing. Whoo! I hope you understood what I just said.


Thanks again guys,
Robert

T.Willey

  • Needs a day job
  • Posts: 5251
Re: top level xref in model space
« Reply #12 on: November 05, 2007, 01:16:10 PM »
No need to change any line, as it works on '08 (I just tested it).  Put it back, and try again.
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 #13 on: November 05, 2007, 01:40:02 PM »
Tim,

I must be doing something wrong or I am not understanding how
the sequence of prompts.

I went back to the link, copy & paste it to a new lsp.
1.  Open Plot sheet.
2.  Went to model space.tilemode 1
3.  Loaded and called SetOrigLayerProps.lsp
4.  Command: Single layer, or All layers <S>
5.  If I hit Enter or Key-in "S"
    Select object within Xref to copy back original layer properties: error:
    Automation Error. Key not found
6. If I key-in A for All
   Select object within Xref to copy back original layer properties: .....I select part of parent xref..it prompts me again
   Select object within Xref to copy back original layer properties:......what do i do next?
 

T.Willey

  • Needs a day job
  • Posts: 5251
Re: top level xref in model space
« Reply #14 on: November 05, 2007, 01:43:27 PM »
Tim,

I must be doing something wrong or I am not understanding how
the sequence of prompts.

I went back to the link, copy & paste it to a new lsp.
1.  Open Plot sheet.
2.  Went to model space.tilemode 1
3.  Loaded and called SetOrigLayerProps.lsp
4.  Command: Single layer, or All layers <S>
5.  If I hit Enter or Key-in "S"
    Select object within Xref to copy back original layer properties: error:
    Automation Error. Key not found
6. If I key-in A for All
   Select object within Xref to copy back original layer properties: .....I select part of parent xref..it prompts me again
   Select object within Xref to copy back original layer properties:......what do i do next?
 

What you want is the 'all' option, so 'a' is okay.  You might be selecting a nested item inside the xref.  I don't I coded for that since I don't use nested xrefs.  After you hit 'all' and pick a point, hit enter to exit the command.  Does it not show the correct color and linetype for the layers in the main xref?
Tim

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

Please think about donating if this post helped you.