SergeM Posted August 19, 2008 Posted August 19, 2008 Hello, Is this possible without refeditting an xref???? Thanks Serge Quote
ML0940 Posted August 21, 2008 Posted August 21, 2008 Yes it is With code, you would have to grab the entities by Block Definition, then change their color properties to by layer. Are you referring to a specific block reference, are they xrefs or are you looking to change all of the aforementioned entities in the drawing to by layer? Serge, I can only supply the answer in VBA, is that ok? ML Quote
SergeM Posted August 23, 2008 Author Posted August 23, 2008 Hello, VBA is ok. I would like to change all of the aforementioned entities of the xref(s) in the drawing to by layer. Thanks, Serge Quote
ML0940 Posted August 26, 2008 Posted August 26, 2008 Hey Serge, Sorry it took so long, I have been pretty busy. To answer your question, yes, we can do this without using xref; we have to edit the block definition table, that is what we are doing below in this code. We have to first check if the block is in fact an xref; If so, then check for that particular xref name. If the name matches, then change ALL entities for that xref to Bylayer As far as Dim Styles, that will have to be handled separately but I think that all other objects that can be changed are handled below. It seems to be working well for me. Let me know how you make out ML Sub XrefEntsToByLayer() Dim Blk As AcadBlock Dim xrEnt As AcadEntity For Each Blk In ThisDrawing.Blocks If Not Blk.IsLayout Then If Blk.IsXRef Then If Blk.Name = "xrefname" Then 'Replace xrefname with the name of your xref 'MsgBox Blk.Name For Each xrEnt In Blk 'xrEnt.Layer = "0" 'If you want to change the xref layer. xrEnt.color = acByLayer xrEnt.LinetypeScale = acByLayer xrEnt.Lineweight = acLnWtByLayer xrEnt.Update Next xrEnt End If End If End If Next Blk ThisDrawing.Regen acActiveViewport End Sub Quote
ML0940 Posted August 26, 2008 Posted August 26, 2008 Wow, Serge That is pretty bizarre how that code works. It is doing exactly what you asked, I think. It is putting all entities in the xref bylayer, using the xref's source bylayer properties but it only appears to be updating in the current drawing ONLY and not effecting the source file. I'm not sure if this was your intents? Let me know ML Quote
SergeM Posted August 26, 2008 Author Posted August 26, 2008 , That's exactly what i want. I will give it a try tomorrow and let you know this friday. (if that's ok for you). When this works i will be able to give one specific color to all the layers of the xref in combination with the lisp i mentioned in another thread and that i got from Jason Piercy . (See below) Could you also test this for me? (defun c:adjustXref (/ lst ename object name) (setvar "errno" 0) (while (/= 52 (getvar "errno")) (setq lst (entsel "\nselect an xref : ")) (cond ((= 7 (getvar "errno")) (princ "\nMiss pick") (setvar "errno" 0) ) ((and lst (setq ename (car lst)) (setq object (vlax-ename->vla-object ename)) (vlax-property-available-p object 'path) ) (setq name (vla-get-name object)) (command "layer" "c" 252 (strcat name "|*") "" "") (command "draworder" ename "" "back") ) (lst (princ "\nselection was not an xref")) (t (setvar "errno" 52)) ) ) (princ) ) I hope this would be a breakthrough for plotting xref's in only one specific color (in this example the color252). Thanks in advance. Serge Quote
SergeM Posted August 26, 2008 Author Posted August 26, 2008 o yeah i forgot, Could you show how to deal with dimensions. Then it will be solved i think. Serge Quote
ML0940 Posted August 26, 2008 Posted August 26, 2008 , That's exactly what i want. I will give it a try tomorrow and let you know this Friday. (if that's OK for you). Hi Serge, I'm glad that is what you needed. So, you are OK that the source xref is not being affected? At least last night it wasn't, I can test again. It makes sense because, we are grabbing the block as opposed to the actual xref itself. In your OP, you mentioned Refedit; Refedit is great if used carefully and wisely. Refedit actually affects the source file, whereas the code that I gave you is using info from the source but not affecting the source. So, if that is truly what you needed , then that is great : ) I'm sure we could grab the actual source xref file as well, as Refedit would achieve; there is an acadexternalreference object, I would just need to look at it more. Serge, I am not big too big on LISP but if you want to send me a sample of the file, I will try The LISP routine, I just would not be able to help you tweak it really. I know a very little about LISP. Sure, we can likely set the dim style you want as active. Please tell me the dim style name that you are working with. Also, one last thing, I tried to set the line type to bylayer but I kept getting, key not found. My guess is that the problem there would be that different entities can be on different layers, and each layer can have its own assigned line type. So, if we were to put all xref entities onto one layer (I gave that ability in the code) then we could likely change that layer's line type to bylayer, depending on your needs. ML Quote
ML0940 Posted August 26, 2008 Posted August 26, 2008 Wow I just realized something That code that I gave to you would be useful if for some reason you wanted to make all the entities in the source xref all different colors, line weights etc for display purposes, however, when it is actually being xref's into another drawing, you want to use the initial bylayer settings for whatever reasons, I think in your case, to plot. My guess is, this is what you are doing? ML Quote
SergeM Posted August 29, 2008 Author Posted August 29, 2008 Hi Serge, I'm glad that is what you needed. So, you are OK that the source xref is not being affected? At least last night it wasn't, I can test again. It makes sense because, we are grabbing the block as opposed to the actual xref itself. In your OP, you mentioned Refedit; Refedit is great if used carefully and wisely. Refedit actually affects the source file, whereas the code that I gave you is using info from the source but not affecting the source. ML Yes indeed the xref must not be affected. Serge, I am not big too big on LISP but if you want to send me a sample of the file, I will try The LISP routine, I just would not be able to help you tweak it really. I know a very little about LISP.ML Just copy the lisp into the comandline and use adjustxref to load the lisp. Thanks Serge Quote
SergeM Posted August 29, 2008 Author Posted August 29, 2008 Sure, we can likely set the dim style you want as active. Please tell me the dim style name that you are working with. ML Look for example in the properties of a dimension line. All colors mentioned in the properties have to change to color by layer. Can you do that in VBA for all possible dimensions? Wow I just realized something That code that I gave to you would be useful if for some reason you wanted to make all the entities in the source xref all different colors, line weights etc for display purposes, however, when it is actually being xref's into another drawing, you want to use the initial bylayer settings for whatever reasons, I think in your case, to plot. My guess is, this is what you are doing? ML After setting all the colors to color bylayer I want to juse the adjustxref wich sets all the nested colors to color 252. (the lisp only works when all nested colors are set to color by layer) The color 252 mentioned in the lisp, is for plotting only the xref(s) as a background. I m sure you could help me further on now. Thanks Serge Quote
ML0940 Posted August 29, 2008 Posted August 29, 2008 Hi Serge, You're Welcome Yes, I know how to make The Lisp file and run it, I just wasn't sure if I really needed to, in order to help you? Is the other code that I supplied working properly then? After setting all the colors to color bylayer I want to juse the adjustxref wich sets all the nested colors to color 252. (the lisp only works when all nested colors are set to color by layer) The color 252 mentioned in the lisp, is for plotting only the xref(s) as a background. I m sure you could help me further on now. I see. I wonder why the person that did The Lisp routine did not address that? Do you know how to run the The VBA Project/macro, then the Lisp routine directly after it? If not, I can help you with that. I would need the VBA Project (.dvb) name, the module name and the macro name that you decided on. Also, The Lisp routine name and the command, which I think is adjustxref. Look for example in the properties of a dimension line. All colors mentioned in the properties have to change to color by layer. Can you do that in VBA for all possible dimensions? So, are you saying that you want all dimensions on the current drawing ByLayer? Will there also be dimensions on the source drawing (xref) or just in the current drawing? The color 252 mentioned in the lisp, is for plotting only the xref(s) as a background. Consider this, we can create a layer called xref (or whatever) put all the xref entities on that layer and make that layer's color 252. If you did that, you can possibly ditch The Lisp routine altogether; then we would not even have needed to address the whole Bylayer issue. Another way to skim the cat: I'm not sure of you are using ctb or stb but you could create a a pen style file for gray scale plotting. User selects that pen style when plotting, then all layers are directed to plot at 252. If you do that, then perhaps no automation is needed at all Unless, I am missing something critical in all of this? ML Quote
ML0940 Posted August 30, 2008 Posted August 30, 2008 Hey Serge, Give this a shot. This will put all dimension, entity's colors in the current drawing to Bylayer. Is that what you needed? ML Sub DimEntsToByLayer() Dim Ent As AcadEntity Dim Sset As AcadSelectionSet On Error Resume Next ThisDrawing.SelectionSets.Item("dims").Delete Set Sset = ThisDrawing.SelectionSets.Add("dims") Sset.Select acSelectionSetAll For Each Ent In Sset If TypeOf Ent Is AcadDimension Then Ent.color = acByLayer End If Next Ent Sset.Delete End Sub Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.