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

XREF LAYER IN LISP

15 REPLIES 15
Reply
Message 1 of 16
Anonymous
878 Views, 15 Replies

XREF LAYER IN LISP

I am a low level lisp writer, so bear with my stupidity. I need to know how to change the layer of all xrefs in a lips routine.
I have written a program to setup a print tab and zoom in at the right size for printing. The only thing is some of the xref might be on the layout layer and i need tham on the block layer to print out. I would like the print tab setup routine to change the layer of all xrefs to the block layer before printing.
Can this be done????
15 REPLIES 15
Message 2 of 16
Anonymous
in reply to: Anonymous

Yes, this can be done. Here's a start for you. First get all of the "inserts" in the drawing: (setq ss (ssget "x" '((0 . "INSERT")))) Then loop thru the ss to find any xrefs: (setq count 0) (repeat (sslength ss) (setq ent (entget (ssname ss count))) ;;convert to vla-object & check if it's an xref (setq ent (vlax-ename->vla-object ent)) (if (= (vla-get-isxref ent) :vlax-true) ;;if it is, change to blocklayer (vla-put-layer ent "blocklayer") );;end if (setq count (1+ count)) ) HTH, Jeff "TYLERW" wrote in message news:21375771.1079971434013.JavaMail.jive@jiveforum2.autodesk.com... > I am a low level lisp writer, so bear with my stupidity. I need to know how to change the layer of all xrefs in a lips routine. > I have written a program to setup a print tab and zoom in at the right size for printing. The only thing is some of the xref might be on the layout layer and i need tham on the block layer to print out. I would like the print tab setup routine to change the layer of all xrefs to the block layer before printing. > Can this be done????
Message 3 of 16
Anonymous
in reply to: Anonymous

I have ran the code you supplied but it is not working. I keep getting a bad argument type when i hit (setq ent (vlax-ename->vla-object ent)). The code selects the inserted objects fine, but then when it changes to name the object that's when it stalls.

Also I am not knowledgable about vla's or how they work. If some one could help me understand that would be great.
Message 4 of 16
Anonymous
in reply to: Anonymous

Sorry, you must have at least one lisp routine in each drawing that initializes the vla-commands. Add the following line to your code anywhere prior to that (setq ent ... line. (vl-load-com) As for the vla- commands, they are adaptations of the Visual Basic/ActiveX properties & methods. The best places to learn about these, IMHO, are: 1. This newsgroup 2. The ActiveX and VBA help files 3. "The Visual Lisp Developer's Bible", available at www.dsxcad.com 4. AcadX.com for sample code and some good articles. Good Luck, Jeff "TYLERW" wrote in message news:31370420.1080059857338.JavaMail.jive@jiveforum2.autodesk.com... > I have ran the code you supplied but it is not working. I keep getting a bad argument type when i hit (setq ent (vlax-ename->vla-object ent)). The code selects the inserted objects fine, but then when it changes to name the object that's when it stalls. > > Also I am not knowledgable about vla's or how they work. If some one could help me understand that would be great.
Message 5 of 16
Anonymous
in reply to: Anonymous

Added the line and still getting same error code
bad argument type: lentityp then goes on to tell about the object that was selected out of the list.
Message 6 of 16
Anonymous
in reply to: Anonymous

Hmmm, guess I'm not yet qualified to put up code without checking to see if it works first. I mixed the use of properties with incorrect objects and that won't work. My apologies! Here's one that does work. Change the layer name to what you want, right now it's set for layer "0". Jeff (defun c:xref2lay (/ ss count ent lay) (vl-load-com) (setq lay "0");change this to layer you want (vla-add (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) lay);create the layer if it doesn't exist, OK if it does (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (= (vla-get-isxref blk) :vlax-true) (progn (if (setq ss (ssget "x" (list (cons 2 (vla-get-name blk))))) (progn (setq count 0) (repeat (sslength ss) (setq ent (ssname ss count)) ;;convert to vla-object (setq ent (vlax-ename->vla-object ent)) (vla-put-layer ent lay) (setq count (1+ count)) ) ) ) ) ) ) (princ) ) "TYLERW" wrote in message news:4958753.1080064004802.JavaMail.jive@jiveforum1.autodesk.com... > Added the line and still getting same error code > bad argument type: lentityp then goes on to tell about the object that was selected out of the list.
Message 7 of 16
EC-CAD
in reply to: Anonymous

Jeff,
I found the entity/object problem with 1st post, was working on it when you re-posted...
On running this code..I get a message" too few actual parameters" ?
And, can't seem to find a reference to: (vla-get-isxref blk).
Searched the 'bible' and 'Help'..nada on the 'isxref'..
Curious.

Bob
Message 8 of 16
EC-CAD
in reply to: Anonymous

Was wondering if this would do the trick.
-------------
(defun C:doit ()
(setq ss (ssget "x" '((0 . "INSERT"))))
(setq count 0)
(repeat (sslength ss)
(setq obj (ssname ss count))
(setq ent (entget obj))
(setq olayer (cdr (assoc 8 ent)))
(if (/= olayer "0")
(progn
(setq dxf70 (cdr (assoc 70 ent))); get dxf 70 codes
(if (or (= dxf70 4)(= dxf70 8)); xref
(command "change" obj "" "P" "LA" "newlayer" "")
);end if
);end progn
);end if
(setq count (1+ count))
);end repeat
);efun
-----------------
Bob
Message 9 of 16
Anonymous
in reply to: Anonymous

OK, so it's only Tuesday and it's already been a long week. I added the layer check AFTER I'd tested to make sure it works.....sigh This line: (vla-add (vla-get-blocks should be: (vla-add (vla-get-layers Bob, the "isxref" is a property of a block definition object. It is defined/described in the ActiveX and VBA reference. Off to drink some strong coffee and get my eyes checked, Jeff "ECCAD" wrote in message news:17851068.1080069513602.JavaMail.jive@jiveforum2... > Jeff, > I found the entity/object problem with 1st post, was working on it when you re-posted... > On running this code..I get a message" too few actual parameters" ? > And, can't seem to find a reference to: (vla-get-isxref blk). > Searched the 'bible' and 'Help'..nada on the 'isxref'.. > Curious. > > Bob
Message 10 of 16
Anonymous
in reply to: Anonymous

THANKS FOR ALL THE HELP. GOT IT UP AND RUNNING. WORKS GREAT. THIS SITE ROCKS FOR PEOPLE WILLING TO HELP OUT.
Message 11 of 16
EC-CAD
in reply to: Anonymous

Tylerw,
Glad to be of help. Keep in touch..
:)
Bob
Message 12 of 16
EC-CAD
in reply to: Anonymous

Jeff,
Yaaaaa, I have had those days too..
:))
Bob
Message 13 of 16
Anonymous
in reply to: Anonymous

From my DXF file, the group 70 for an insert is: Column count (optional; default = 1) To use the dxf code 70 you would need the block definition from the block table. Also, you can't check for the value being equal to 4 or 8 since it is a bit-coded value and for a resolved/attached xref it is actually 36 (4 + 32). This is why I chose the ActiveX route, "isXref" returns true or false. Jeff "ECCAD" wrote in message news:10091310.1080069732713.JavaMail.jive@jiveforum2... > Was wondering if this would do the trick. > ------------- > (defun C:doit () > (setq ss (ssget "x" '((0 . "INSERT")))) > (setq count 0) > (repeat (sslength ss) > (setq obj (ssname ss count)) > (setq ent (entget obj)) > (setq olayer (cdr (assoc 8 ent))) > (if (/= olayer "0") > (progn > (setq dxf70 (cdr (assoc 70 ent))); get dxf 70 codes > (if (or (= dxf70 4)(= dxf70 8)); xref > (command "change" obj "" "P" "LA" "newlayer" "") > );end if > );end progn > );end if > (setq count (1+ count)) > );end repeat > );efun > ----------------- > Bob
Message 14 of 16
EC-CAD
in reply to: Anonymous

Jeff,
I can't seem to find it in my 'help' files anywhere,,possibly
something new in R2004 ?
Bob
Message 15 of 16
Anonymous
in reply to: Anonymous

Nope, I'm in 2002. Again, it's in the "ActiveX and VBA Reference" which is a part of the "Developer Documentation". Here's the page from that help document: Determines if the given block is an XRef block. See Also | Example Signature object.IsXRef object Block The object or objects this property applies to. IsXRef Boolean; read-only TRUE: The block is an XRef. FALSE: The block is not an XRef. Remarks The IsXRef property works with the IsLayout property. If both properties are FALSE, then the block is a simple block. If the IsXRef property is TRUE, then the block is an external reference. If the IsLayout property is TRUE, then the block contains all the geometry associated with a layout. Jeff "ECCAD" wrote in message news:17527164.1080071273932.JavaMail.jive@jiveforum2... > Jeff, > I can't seem to find it in my 'help' files anywhere,,possibly > something new in R2004 ? > Bob
Message 16 of 16
EC-CAD
in reply to: Anonymous

Jeff,
Thanks.!
I'll dig into it.
Appreciated.
Bob

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

Post to forums  

Autodesk Design & Make Report

”Boost