Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unloading XREFs only in paperspace

13 REPLIES 13
Reply
Message 1 of 14
cpguy33
382 Views, 13 Replies

Unloading XREFs only in paperspace

I am trying to figure out a lisp program to detach the XREFs only on paper space, not modelspace, and save the path(s) to re-attach it later.

Or if I could just get the names of the XREFs only on modelspace that would work too.

The final program that I am going to create is to change the color of all of the model space XREFs layers to 8 and do nothing to the XREFs on paperspace or any other layer.

I want this program to require no user intervention besides calling the program to run.
13 REPLIES 13
Message 2 of 14
Anonymous
in reply to: cpguy33

DXF code 67 determines what space a graphical
object resides in. You can include it in a filter list
passed to the ssget function.

Once a selection set has been defined, you can step
through it and make the desired changes.

What have you tried so far, code wise?


--
Autodesk Discussion Group Facilitator


wrote in message news:4925467@discussion.autodesk.com...
I am trying to figure out a lisp program to detach the XREFs only on paper space, not modelspace, and save the path(s) to re-attach
it later.

Or if I could just get the names of the XREFs only on modelspace that would work too.

The final program that I am going to create is to change the color of all of the model space XREFs layers to 8 and do nothing to the
XREFs on paperspace or any other layer.

I want this program to require no user intervention besides calling the program to run.
Message 3 of 14
Anonymous
in reply to: cpguy33

taking a quick stab here...

don't detach or unload anything.

make sure you are in modelspace.
create a selection set of blocks using the ":C" filter.
":C" rejects objects that are not in the current space.
when you cycle through the blocks in your selection set, if the block is an
xref, use the name of the xref as the layer prefix <"XrefNamePrefix|*"> and
change the color of those layers to 8.

--
Daron
Whether a man winds up with
a nest egg, or a goose egg,
depends a lot on the kind of
chick he marries.



wrote in message news:4925467@discussion.autodesk.com...
I am trying to figure out a lisp program to detach the XREFs only on paper
space, not modelspace, and save the path(s) to re-attach it later.

Or if I could just get the names of the XREFs only on modelspace that would
work too.

The final program that I am going to create is to change the color of all of
the model space XREFs layers to 8 and do nothing to the XREFs on paperspace
or any other layer.

I want this program to require no user intervention besides calling the
program to run.
Message 4 of 14
t.willey
in reply to: cpguy33

Have fun.

Tim

(defun c:ListXref (/ ActDoc tmpList EndList)

(vl-load-com)
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vlax-for Layout (vla-get-Layouts ActDoc)
(setq tmpList nil)
(vlax-for i (vla-get-Block Layout)
(if
(and
(= (vla-get-ObjectName i) "AcDbBlockReference")
(vlax-property-available-p i 'Path)
)
(setq tmpList (cons (cons i (vla-get-Name i)) tmpList))
)
)
(if tmpList
(setq EndList (cons (vla-get-Name Layout) tmpList))
)
)
EndList
)
Message 5 of 14
t.willey
in reply to: cpguy33

Posted to soon. Here is the corrected one.

Tim

ps. The number signs are supposed to be the vla-object name returned for that xref. The code works, it's just the web site interface doesn't like what it returns.

(defun ListXref (Doc / tmpList EndList)
;| List all xref's within a drawing (document).
Use like: (setq XrefList (ListXref nil)) for current drawing, or give a valid drawing (document) object.
Returns = (("Model" (# . "Base-Plan"))
("Layout1" (# . "Title-Block"))
)
;|

(vl-load-com)
(if (not Doc)
(setq Doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
)
(vlax-for Layout (vla-get-Layouts ActDoc)
(setq tmpList nil)
(vlax-for i (vla-get-Block Layout)
(if
(and
(= (vla-get-ObjectName i) "AcDbBlockReference")
(vlax-property-available-p i 'Path)
)
(setq tmpList (cons (cons i (vla-get-Name i)) tmpList))
)
)
(if tmpList
(setq EndList (cons (cons (vla-get-Name Layout) tmpList) EndList))
)
)
EndList
)
Message 6 of 14
Anonymous
in reply to: cpguy33

Tlm, to get the web interface to display correctly, try wrapping everything
in CODE tags...

[ code]place your code between these tags, ommitting the spaces in them, I
had to add the spaces or else this would be wrapped too[ /code]

wrote in message news:4926063@discussion.autodesk.com...
Posted to soon. Here is the corrected one.

Tim

ps. The number signs are supposed to be the vla-object name returned for
that xref. The code works, it's just the web site interface doesn't like
what it returns.
Message 7 of 14
t.willey
in reply to: cpguy33

[code](defun ListXref (Doc / tmpList EndList)
;| List all xref's within a drawing (document).
Returns = (("Model" (# . "Base-Plan"))
("Layout1" (# . "Title-Block"))
)
;|

(if (not Doc)
(setq Doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
)
(vlax-for Layout (vla-get-Layouts ActDoc)
(setq tmpList nil)
(vlax-for i (vla-get-Block Layout)
(if
(and
(= (vla-get-ObjectName i) "AcDbBlockReference")
(vlax-property-available-p i 'Path)
)
(setq tmpList (cons (cons i (vla-get-Name i)) tmpList))
)
)
(if tmpList
(setq EndList (cons (cons (vla-get-Name Layout) tmpList) EndList))
)
)
EndList
)[/code]

It still won't display the vla-object correctly. I had tried that, but I had the wrong call out for the code beginning and ending. I was trying [ code/ ] ... code here... [ code ], but this would just put everything in one paragraph.

Thanks for telling me how to do it correctly.
Tim
Message 8 of 14
cpguy33
in reply to: cpguy33

The code that I have previously written to change all of the XREF layers the color 8 is:

(defun NEW_APP( / el tp xrefname ss1)
(setq el (tblnext "BLOCK" T))
(vl-cmdf "._layer")
(while el
(if (setq tp (assoc 1 el))
(progn
(setq xrefname (cdr (assoc 2 el)))
(vl-cmdf "c" "8" (strcat xrefname "*"))
)
)
(setq el (tblnext "BLOCK"))
)
(vl-cmdf "")
)

As is said that changes all of the XREF layers to 8. How would I implement your program into this code to have it work? I am a novice c++ programmer and I just started to learn how to program LISP functions on monday, so bear with me.
Message 9 of 14
t.willey
in reply to: cpguy33

What mine retruns is a list of lists. I would do it like.

(setq XrefList (ListXref nil)) ; for current drawing.
(foreach SpaceList XrefList
(if (= (car SpaceList) "Model")
(setq LayCol "8")
(setq LayCol "9")
)
(foreach Name (cdr SpaceList)
(print Name)
(command "_.layer" "_c" LayCol (strcat (cdr Name) "|*") "")
)
)

If you have any questions look in the help, or you can post here and someone might tell you to look in the help, or will explain what is going on.

Tim
Message 10 of 14
t.willey
in reply to: cpguy33

Use this one instead. I had something wrong in the first one I posted.

Tim

(defun ListXref (Doc / tmpList EndList)
;| List all xref's within a drawing (document).
Returns = (("Model" (# . "Base-Plan"))
("Layout1" (# . "Title-Block"))
)
|;

(if (not Doc)
(setq Doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
)
(vlax-for Layout (vla-get-Layouts Doc)
(setq tmpList nil)
(vlax-for i (vla-get-Block Layout)
(if
(and
(= (vla-get-ObjectName i) "AcDbBlockReference")
(vlax-property-available-p i 'Path)
)
(setq tmpList (cons (cons i (vla-get-Name i)) tmpList))
)
)
(if tmpList
(setq EndList (cons (cons (vla-get-Name Layout) tmpList) EndList))
)
)
EndList
)
Message 11 of 14
cpguy33
in reply to: cpguy33

The program works great, the only problem I'm having is with nested xrefs. How would you modify this program to include the nested xrefs on modelspace?
Message 12 of 14
t.willey
in reply to: cpguy33

Try this revised one.

Tim

(defun ListXref (Doc / tmpList EndList)
;| List all xref's within a drawing (document), nested Xrefs also.
Returns = (("Model" (# . "Base-Plan"))
("Layout1" (# . "Title-Block"))
)
|;

(if (not Doc)
(setq Doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
)
(setq BlkCol (vla-get-Blocks Doc))
(vlax-for Layout (vla-get-Layouts Doc)
(setq tmpList nil)
(vlax-for i (vla-get-Block Layout)
(if
(and
(= (vla-get-ObjectName i) "AcDbBlockReference")
(vlax-property-available-p i 'Path)
)
(progn
(if (not (member (vla-get-Name i) tmpList))
(setq tmpList (cons (vla-get-Name i) tmpList))
)
(setq tmpBlk (vla-Item BlkCol (vla-get-Name i)))
(vlax-for Obj tmpBlk
(if
(and
(= (vla-get-ObjectName Obj) "AcDbBlockReference")
(vlax-property-available-p Obj 'Path)
)
(if (not (member (vla-get-Name Obj) tmpList))
(setq tmpList (cons (vla-get-Name Obj) tmpList))
)
)
)
)
)
)
(if tmpList
(progn
(setq tmpList (mapcar '(lambda (x) (cons (vla-Item BlkCol x) x)) tmpList))
(setq EndList (cons (cons (vla-get-Name Layout) tmpList) EndList))
)
)
)
EndList
)
Message 13 of 14
cpguy33
in reply to: cpguy33

Thank you very much.
The program works great!
Message 14 of 14
t.willey
in reply to: cpguy33

You're welcome.

Tim

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost