|
Replies:
19
-
Last Post:
Mar 25, 2009 1:00 PM
Last Post By: Some Buddy
|
|
|
|
|
|
|
HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 15, 2009 3:14 PM
|
|
|
|
I have a need to take blocks that are in a drawing file for example and scan the blocks for Attributes or Text and change the layers on which the Attributes or text reside, nothing else.
Is there someone out there interested in either providing a program that will do this or write one that can be in lisp not VB. I can pay if the price is right.
Thank you
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 16, 2009 1:13 PM
in response to: BIM is in
|
|
|
|
Hi,
Would this scan include Xrefs ?
-- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
"BIM is in" a écrit dans le message de news: 6142471@discussion.autodesk.com... I have a need to take blocks that are in a drawing file for example and scan the blocks for Attributes or Text and change the layers on which the Attributes or text reside, nothing else.
Is there someone out there interested in either providing a program that will do this or write one that can be in lisp not VB. I can pay if the price is right.
Thank you
|
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 19, 2009 7:57 AM
in response to: Some Buddy
|
|
|
|
No it would not include xrefs
"Some Buddy" wrote in message news:6142691@discussion.autodesk.com... Hi,
Would this scan include Xrefs ?
-- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
"BIM is in" a écrit dans le message de news: 6142471@discussion.autodesk.com... I have a need to take blocks that are in a drawing file for example and scan the blocks for Attributes or Text and change the layers on which the Attributes or text reside, nothing else.
Is there someone out there interested in either providing a program that will do this or write one that can be in lisp not VB. I can pay if the price is right.
Thank you
|
|
|
|
|
Posts:
236
Registered:
02/23/09
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 17, 2009 3:14 AM
in response to: BIM is in
|
|
|
|
Yes this is very possible. but when you say text do you mean "text attributes" ? I ask because in my opinion it is difficult to search through blocks for text and much easier to do this if you have an attribute tag. And as far as i know you would have to re-block the specified block in order to change the text. - this is why attributes are so beautiful. - :D
|
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 19, 2009 7:58 AM
in response to: balisteor
|
|
|
If yu have somehting that will address the attributes and change the layer and style that would be great. Yes this is very possible. but when you say text do you mean "text attributes" ? I ask because in my opinion it is difficult to search through blocks for text and much easier to do this if you have an attribute tag. And as far as i know you would have to re-block the specified block in order to change the text. - this is why attributes are so beautiful. - :D
|
|
|
|
|
Posts:
236
Registered:
02/23/09
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 19, 2009 2:53 PM
in response to: BIM is in
|
|
|
|
I want to ask you more questions there are so many other options you can add such as block filtration and wich blocks receive the style changes and wich ones recieve the layer changes
but im sure you may just want to try out some code so here you go. please test this out after loading all these functions. ( Ill assume you have worked with lisp before and can load and rename them how you wish)
the important functions are entgatt and att_prop and are a couple of my favorites because i use them alot!
( defun entgatt ( eg_tag eg_ent / eg_out ) ;; GETS THE DESIRED ATTRIBUTES ENTITY LIST
( while ( not ( = "SEQEND" ( cdr ( assoc 0 ( entget eg_ent )))) )
( if ( = eg_tag ( cdr ( assoc 2 ( entget eg_ent ))) )
( setq eg_out ( entget eg_ent )) );i
( setq eg_ent ( entnext eg_ent ))
)
( setq eg_out eg_out )
)
;; *Changes any Dxf code for any attribute..
example --> ( att_prop [attribute tag name],[entity name],[dxf code number],[dxf code new value] )
;; needs entgatt function***
( defun att_prop ( att_prop_name att_prop_en att_prop_code att_prop_nv )
( entmod ( subst ( cons att_prop_code att_prop_nv ) ( assoc att_prop_code ( entgatt att_prop_name att_prop_en ) ) ( entgatt att_prop_name att_prop_en ) ) )
( entupd ( cdr ( assoc -1 ( entgatt att_prop_name att_prop_en ))))
)
;;DXF CODE REFERENCE
;;7 Text style name (optional; default = STANDARD)
;;8 layer name
( defun C:TESTING123 ( / att_layername att_stylename att_tagname ) ;;
( setq att_layername ( getstring "\nEnter layer for attribute:" T ))
( setq att_stylename ( getstring "\nEnter layer for attribute:" T ))
( setq att_tagname ( getstring "\nEnter attribute tag name:" ))
( setq ent ( car ( entsel )))
( att_prop att_tagname ent 8 att_layername ) << --- CODE 8 IS FOR LAYER
( att_prop att_tagname ent 7 att_stylename ) << --- CODE 7 IS FOR STYLE
(princ ))
|
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 21, 2009 9:43 PM
in response to: balisteor
|
|
|
OK i figured out what your doing in this, however it involves picking one at a time. A few items.... 1. Since your asking for the tag name it needs to be typed exactly as it is case senistive. Would be easier if it could select them all which is my original problem as there are several different tag names. Is it possible to hard code the style names and loop it or use another mether that does not involve making selections. 2. ( setq att_layername ( getstring "\nEnter layer for attribute:" T )) ( setq att_stylename ( getstring "\nEnter layer for attribute:" T )) ;;;I assume you mean to ask Enter new style name. This is nice as it does what I want partially. I would need to add changing the oblique angle to "0" as well while I am at it. I will contiue to play with this and see if I can make the changes. Bob ------------------------------------------------------------------------ I want to ask you more questions there are so many other options you can add such as block filtration and wich blocks receive the style changes and wich ones recieve the layer changes
but im sure you may just want to try out some code so here you go. please test this out after loading all these functions. ( Ill assume you have worked with lisp before and can load and rename them how you wish)
the important functions are entgatt and att_prop and are a couple of my favorites because i use them alot!
( defun entgatt ( eg_tag eg_ent / eg_out ) ;; GETS THE DESIRED ATTRIBUTES ENTITY LIST
( while ( not ( = "SEQEND" ( cdr ( assoc 0 ( entget eg_ent )))) )
( if ( = eg_tag ( cdr ( assoc 2 ( entget eg_ent ))) )
( setq eg_out ( entget eg_ent )) );i
( setq eg_ent ( entnext eg_ent ))
)
( setq eg_out eg_out )
)
;; *Changes any Dxf code for any attribute..
example --> ( att_prop [attribute tag name],[entity name],[dxf code number],[dxf code new value] )
;; needs entgatt function***
( defun att_prop ( att_prop_name att_prop_en att_prop_code att_prop_nv )
( entmod ( subst ( cons att_prop_code att_prop_nv ) ( assoc att_prop_code ( entgatt att_prop_name att_prop_en ) ) ( entgatt att_prop_name att_prop_en ) ) )
( entupd ( cdr ( assoc -1 ( entgatt att_prop_name att_prop_en ))))
)
;;DXF CODE REFERENCE
;;7 Text style name (optional; default = STANDARD)
;;8 layer name
( defun C:TESTING123 ( / att_layername att_stylename att_tagname ) ;;
( setq att_layername ( getstring "\nEnter layer for attribute:" T ))
( setq att_stylename ( getstring "\nEnter layer for attribute:" T ))
( setq att_tagname ( getstring "\nEnter attribute tag name:" ))
( setq ent ( car ( entsel )))
( att_prop att_tagname ent 8 att_layername ) << --- CODE 8 IS FOR LAYER
( att_prop att_tagname ent 7 att_stylename ) << --- CODE 7 IS FOR STYLE
(princ ))
|
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 21, 2009 10:46 PM
in response to: BIM is in
|
|
|
Autolisp says it checks out fine, but when I run the program it says "to few arguments"
OK i figured out what your doing in this, however it involves picking one at a time. A few items.... 1. Since your asking for the tag name it needs to be typed exactly as it is case senistive. Would be easier if it could select them all which is my original problem as there are several different tag names. Is it possible to hard code the style names and loop it or use another mether that does not involve making selections. 2. ( setq att_layername ( getstring "\nEnter layer for attribute:" T )) ( setq att_stylename ( getstring "\nEnter layer for attribute:" T )) ;;;I assume you mean to ask Enter new style name. This is nice as it does what I want partially. I would need to add changing the oblique angle to "0" as well while I am at it. I will contiue to play with this and see if I can make the changes. Bob ------------------------------------------------------------------------ I want to ask you more questions there are so many other options you can add such as block filtration and wich blocks receive the style changes and wich ones recieve the layer changes
but im sure you may just want to try out some code so here you go. please test this out after loading all these functions. ( Ill assume you have worked with lisp before and can load and rename them how you wish)
the important functions are entgatt and att_prop and are a couple of my favorites because i use them alot!
( defun entgatt ( eg_tag eg_ent / eg_out ) ;; GETS THE DESIRED ATTRIBUTES ENTITY LIST
( while ( not ( = "SEQEND" ( cdr ( assoc 0 ( entget eg_ent )))) )
( if ( = eg_tag ( cdr ( assoc 2 ( entget eg_ent ))) )
( setq eg_out ( entget eg_ent )) );i
( setq eg_ent ( entnext eg_ent ))
)
( setq eg_out eg_out )
)
;; *Changes any Dxf code for any attribute..
example --> ( att_prop [attribute tag name],[entity name],[dxf code number],[dxf code new value] )
;; needs entgatt function***
( defun att_prop ( att_prop_name att_prop_en att_prop_code att_prop_nv )
( entmod ( subst ( cons att_prop_code att_prop_nv ) ( assoc att_prop_code ( entgatt att_prop_name att_prop_en ) ) ( entgatt att_prop_name att_prop_en ) ) )
( entupd ( cdr ( assoc -1 ( entgatt att_prop_name att_prop_en ))))
)
;;DXF CODE REFERENCE
;;7 Text style name (optional; default = STANDARD)
;;8 layer name
( defun C:TESTING123 ( / att_layername att_stylename att_tagname ) ;;
( setq att_layername ( getstring "\nEnter layer for attribute:" T ))
( setq att_stylename ( getstring "\nEnter layer for attribute:" T ))
( setq att_tagname ( getstring "\nEnter attribute tag name:" ))
( setq ent ( car ( entsel )))
( att_prop att_tagname ent 8 att_layername ) << --- CODE 8 IS FOR LAYER
( att_prop att_tagname ent 7 att_stylename ) << --- CODE 7 IS FOR STYLE
(princ ))
|
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 19, 2009 4:43 PM
in response to: BIM is in
|
|
|
Hi, Try the next function. It changes the layer and the text style for text and attribute definitions. If a block is inserted more than one time, all instances will be updated. It will ignore Xrefs, anonymous blocks and dimensions, and it should be called like this: (CHGATTXTLAYSTYLE replacement_layer replacement_style) where replacement_layer is the name of the new layer as string and replacement_style is the name of the new text style, as string. If the layer or the style do not exist, an error alert will pop up. I Hope is what you need. ;;;======================================== (defun chgattxtlaystyle (layer txtstyle / index item) (vl-load-com) (command "_.undo" "_begin") (if (tblsearch "layer" layer) (if (tblsearch "style" txtstyle) (vlax-for block (vla-get-blocks (vla-get-activedocument(vlax-get-acad-object)) ) (if (and (= (vla-get-isXref block) :vlax-false) (wcmatch (vla-get-name block) "~`**") (wcmatch (vla-get-name block) "*Dimension") ) (progn (setq index (vla-get-count block)) (repeat index (setq item (vla-item blockdef (1- index))) (if (wcmatch (vla-get-objectname item) "AcDbAttributeDefinition,AcDbText" ) (progn (vla-put-layer item layer) (vla-put-stylename item txtstyle) (vl-cmdf "_.attsync" "_n" (vla-get-name block)) ) ) (setq index (1- index)) ) ) ) ) (alert (strcat "Style "(strcase txtstyle)" dosen't exist.") ) ) (alert (strcat "Layer "(strcase layer)" dosen't exist.") ) ) (command "_.undo" "_end") (princ) ) ;;;======================================== -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
If yu have somehting that will address the attributes and change the layer and style that would be great. Yes this is very possible. but when you say text do you mean "text attributes" ? I ask because in my opinion it is difficult to search through blocks for text and much easier to do this if you have an attribute tag. And as far as i know you would have to re-block the specified block in order to change the text. - this is why attributes are so beautiful. - :D
|
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 21, 2009 8:52 PM
in response to: Some Buddy
|
|
|
Thanks guy's I will try these and let you know how I make out. I appreciate it.
Hi, Try the next function. It changes the layer and the text style for text and attribute definitions. If a block is inserted more than one time, all instances will be updated. It will ignore Xrefs, anonymous blocks and dimensions, and it should be called like this: (CHGATTXTLAYSTYLE replacement_layer replacement_style) where replacement_layer is the name of the new layer as string and replacement_style is the name of the new text style, as string. If the layer or the style do not exist, an error alert will pop up. I Hope is what you need. ;;;======================================== (defun chgattxtlaystyle (layer txtstyle / index item) (vl-load-com) (command "_.undo" "_begin") (if (tblsearch "layer" layer) (if (tblsearch "style" txtstyle) (vlax-for block (vla-get-blocks (vla-get-activedocument(vlax-get-acad-object)) ) (if (and (= (vla-get-isXref block) :vlax-false) (wcmatch (vla-get-name block) "~`**") (wcmatch (vla-get-name block) "*Dimension") ) (progn (setq index (vla-get-count block)) (repeat index (setq item (vla-item blockdef (1- index))) (if (wcmatch (vla-get-objectname item) "AcDbAttributeDefinition,AcDbText" ) (progn (vla-put-layer item layer) (vla-put-stylename item txtstyle) (vl-cmdf "_.attsync" "_n" (vla-get-name block)) ) ) (setq index (1- index)) ) ) ) ) (alert (strcat "Style "(strcase txtstyle)" dosen't exist.") ) ) (alert (strcat "Layer "(strcase layer)" dosen't exist.") ) ) (command "_.undo" "_end") (princ) ) ;;;======================================== -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
If yu have somehting that will address the attributes and change the layer and style that would be great. Yes this is very possible. but when you say text do you mean "text attributes" ? I ask because in my opinion it is difficult to search through blocks for text and much easier to do this if you have an attribute tag. And as far as i know you would have to re-block the specified block in order to change the text. - this is why attributes are so beautiful. - :D
|
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 21, 2009 9:34 PM
in response to: Some Buddy
|
|
|
This says that chgattxtlaystyle is an unknown command but since you can use it I assume it will work. Also where you say replacement_layer and replacement_style, should I be replacing a temp value in the program where you do a table search and put my style and layer? My old Layer is: G-Anno and the new layer is G-Anno-Text. My old style is RWS and the new style is DIM. Can you re-code this. Bob
Hi, Try the next function. It changes the layer and the text style for text and attribute definitions. If a block is inserted more than one time, all instances will be updated. It will ignore Xrefs, anonymous blocks and dimensions, and it should be called like this: (CHGATTXTLAYSTYLE replacement_layer replacement_style) where replacement_layer is the name of the new layer as string and replacement_style is the name of the new text style, as string. If the layer or the style do not exist, an error alert will pop up. I Hope is what you need. ;;;======================================== (defun chgattxtlaystyle (layer txtstyle / index item) (vl-load-com) (command "_.undo" "_begin") (if (tblsearch "layer" layer) (if (tblsearch "style" txtstyle) (vlax-for block (vla-get-blocks (vla-get-activedocument(vlax-get-acad-object)) ) (if (and (= (vla-get-isXref block) :vlax-false) (wcmatch (vla-get-name block) "~`**") (wcmatch (vla-get-name block) "*Dimension") ) (progn (setq index (vla-get-count block)) (repeat index (setq item (vla-item blockdef (1- index))) (if (wcmatch (vla-get-objectname item) "AcDbAttributeDefinition,AcDbText" ) (progn (vla-put-layer item layer) (vla-put-stylename item txtstyle) (vl-cmdf "_.attsync" "_n" (vla-get-name block)) ) ) (setq index (1- index)) ) ) ) ) (alert (strcat "Style "(strcase txtstyle)" dosen't exist.") ) ) (alert (strcat "Layer "(strcase layer)" dosen't exist.") ) ) (command "_.undo" "_end") (princ) ) ;;;======================================== -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
If yu have somehting that will address the attributes and change the layer and style that would be great. Yes this is very possible. but when you say text do you mean "text attributes" ? I ask because in my opinion it is difficult to search through blocks for text and much easier to do this if you have an attribute tag. And as far as i know you would have to re-block the specified block in order to change the text. - this is why attributes are so beautiful. - :D
|
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 21, 2009 10:36 PM
in response to: BIM is in
|
|
|
Made a few changes below which get me to pick and not type. See ;;;<---------------------------------------- Would still prefer a global chnage of all attributes as well as text in blocks. Maybe If I can get the other one from balisteor running as well I can combine them. ( defun entgatt ( eg_tag eg_ent / eg_out ) ;; GETS THE DESIRED ATTRIBUTES ENTITY LIST ( while ( not ( = "SEQEND" ( cdr ( assoc 0 ( entget eg_ent )))) ) ( if ( = eg_tag ( cdr ( assoc 2 ( entget eg_ent ))) ) ( setq eg_out ( entget eg_ent )) );i ( setq eg_ent ( entnext eg_ent )) ) ( setq eg_out eg_out ) ) ;; *Changes any Dxf code for any attribute.. ;example --> ( att_prop [attribute tag name],[entity name],[dxf code number],[dxf code new value] ) ;; needs entgatt function*** ( defun att_prop ( att_prop_name att_prop_en att_prop_code att_prop_nv ) ( entmod ( subst ( cons att_prop_code att_prop_nv ) ( assoc att_prop_code ( entgatt att_prop_name att_prop_en ) ) ( entgatt att_prop_name att_prop_en ) ) ) ( entupd ( cdr ( assoc -1 ( entgatt att_prop_name att_prop_en )))) ) ;;DXF CODE REFERENCE ;;7 Text style name (optional; default = STANDARD) ;;8 layer name ( defun C:CHA ( / att_layername att_stylename att_tagname ) ;; ;( setq att_layername ( getstring "\nEnter layer for attribute:" T )) ( setq att_layername "G-Anno-Text") ;;;<---------------------------------------- ;( setq att_stylename ( getstring "\nEnter New style for attribute:" T )) ( setq att_stylename "dim");;;<---------------------------------------- ;( setq att_tagname ( getstring "\nEnter attribute tag name:" )) ( setq att-oblq "0");;;<----------------------------------------Need to know CODE for oblique angle ( setq att_tagname "EQP");;;<---------------------------------------- ( setq ent ( car ( entsel ))) ( att_prop att_tagname ent 8 att_layername ) << --- CODE 8 IS FOR LAYER ( att_prop att_tagname ent 7 att_stylename ) << --- CODE 7 IS FOR STYLE ( att_prop att_tagname ent X att-oblq) << --- CODE X IS FOR OBLIQUE (princ ) )
This says that chgattxtlaystyle is an unknown command but since you can use it I assume it will work. Also where you say replacement_layer and replacement_style, should I be replacing a temp value in the program where you do a table search and put my style and layer? My old Layer is: G-Anno and the new layer is G-Anno-Text. My old style is RWS and the new style is DIM. Can you re-code this. Bob
Hi, Try the next function. It changes the layer and the text style for text and attribute definitions. If a block is inserted more than one time, all instances will be updated. It will ignore Xrefs, anonymous blocks and dimensions, and it should be called like this: (CHGATTXTLAYSTYLE replacement_layer replacement_style) where replacement_layer is the name of the new layer as string and replacement_style is the name of the new text style, as string. If the layer or the style do not exist, an error alert will pop up. I Hope is what you need. ;;;======================================== (defun chgattxtlaystyle (layer txtstyle / index item) (vl-load-com) (command "_.undo" "_begin") (if (tblsearch "layer" layer) (if (tblsearch "style" txtstyle) (vlax-for block (vla-get-blocks (vla-get-activedocument(vlax-get-acad-object)) ) (if (and (= (vla-get-isXref block) :vlax-false) (wcmatch (vla-get-name block) "~`**") (wcmatch (vla-get-name block) "*Dimension") ) (progn (setq index (vla-get-count block)) (repeat index (setq item (vla-item blockdef (1- index))) (if (wcmatch (vla-get-objectname item) "AcDbAttributeDefinition,AcDbText" ) (progn (vla-put-layer item layer) (vla-put-stylename item txtstyle) (vl-cmdf "_.attsync" "_n" (vla-get-name block)) ) ) (setq index (1- index)) ) ) ) ) (alert (strcat "Style "(strcase txtstyle)" dosen't exist.") ) ) (alert (strcat "Layer "(strcase layer)" dosen't exist.") ) ) (command "_.undo" "_end") (princ) ) ;;;======================================== -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
If yu have somehting that will address the attributes and change the layer and style that would be great. Yes this is very possible. but when you say text do you mean "text attributes" ? I ask because in my opinion it is difficult to search through blocks for text and much easier to do this if you have an attribute tag. And as far as i know you would have to re-block the specified block in order to change the text. - this is why attributes are so beautiful. - :D
|
|
|
|
|
|
|
|
|
Re:IGNORE ABOVE---READ THIS ONE------ HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 22, 2009 12:37 PM
in response to: BIM is in
|
|
|
This is what I modified. The DXF code for Oblique says its bad, but according to autodesk it says its right. Can you check, did I do something wrong? ( defun entgatt ( eg_tag eg_ent / eg_out ) ;; GETS THE DESIRED ATTRIBUTES ENTITY LIST ( while ( not ( = "SEQEND" ( cdr ( assoc 0 ( entget eg_ent )))) ) ( if ( = eg_tag ( cdr ( assoc 2 ( entget eg_ent ))) ) ( setq eg_out ( entget eg_ent )) );i ( setq eg_ent ( entnext eg_ent )) ) ( setq eg_out eg_out ) ) ;; *Changes any Dxf code for any attribute.. ;example --> ( att_prop [attribute tag name],[entity name],[dxf code number],[dxf code new value] ) ;; needs entgatt function*** ( defun att_prop ( att_prop_name att_prop_en att_prop_code att_prop_nv ) ( entmod ( subst ( cons att_prop_code att_prop_nv ) ( assoc att_prop_code ( entgatt att_prop_name att_prop_en ) ) ( entgatt att_prop_name att_prop_en ) ) ) ( entupd ( cdr ( assoc -1 ( entgatt att_prop_name att_prop_en )))) ) ;;DXF CODE REFERENCE ;;7 Text style name (optional; default = STANDARD) ;;8 layer name ( defun C:CHA ( / att_layername att_stylename att_tagname ) ;;
;( setq att_layername ( getstring "\nEnter layer for attribute:" T )) ( setq att_layername "G-Anno-Text") ;( setq att_stylename ( getstring "\nEnter New style for attribute:" T )) ( setq att_stylename "dim") ( setq att-oblq "0") ;( setq att_tagname ( getstring "\nEnter attribute tag name:" )) ( setq att_tagname "EQP") ( setq ent ( car ( entsel ))) ( att_prop att_tagname ent 8 att_layername ) ;<< --- CODE 8 IS FOR LAYER ( att_prop att_tagname ent 7 att_stylename ) ;<< --- CODE 7 IS FOR STYLE ( att_prop att_tagname ent 51 att_oblq ) ;<< --- CODE 51 IS FOR ANGLE (princ ) )
|
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 23, 2009 1:58 PM
in response to: BIM is in
|
|
|
|
|
It seems to me that you are a little bit lost, but I will try to shed some light on this. The function I gave you is kind of a kernel and you can embed it in your code. The function is supposed to do a global job if used correctly. It uses the ActiveX approach, instead of the DXF approach. The message "unknown command " comes from the fact that you are trying to call my function as a command, which it's not. What I gave you, was defined as a function, not as a command. The difference is the c: placed in the name assigned by (defun ... : (defun C:CHA defines a command which can be called by the name: Command: CHA and will work, but (defun chgattxtlaystyle
defines a function that can not be called directly by the name, but rather in brackets, the same way you use the function (att_prop ... and of course, taking care to pass the right parameters. As for the oblique angle, in the original post you didn't say anything about it but if you want to change this too, use the attached new function. If you want to use the DXF approach, the code for the oblique angle is 51. And since the angle is a numerical value, you don't have to complicate your life passing it as string, but rather as a numerical value. This will spare you the code to convert it to a numerical value. Also note that you don't need to create variables in order to pass the information to a function, and it is possible to pass the necessary information directly, so instead of: (defun C:CHA ( / att_layername att_stylename att-oblq att_tagname ent) (setq att_layername "G-Anno-Text") (setq att_stylename "dim") (setq att-oblq 0) (setq att_tagname "EQP") (setq ent (car (entsel))) (att_prop att_tagname ent 8 att_layername) (att_prop att_tagname ent 7 att_stylename) (att_prop att_tagname ent 51 att-oblq) (princ) ) you can use the next one: (defun C:CHA ( / ent) (setq ent (car (entsel))) (att_prop "EQP" ent 8 "G-Anno-Text") (att_prop "EQP" ent 7 "dim") (att_prop "EQP" ent 51 0) (princ ) ) which is smaller and faster. If you want to try my function, than you should call it like this:
(chgattxtlaystyle "G-Anno-Text" "dim" 0)
where the first argument is the new layer name, the second argument is the new style name and the third argument is the new oblique angle. If you want to used as a command, you could define a command:
(defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0))
As you can see, it will do all the replacements in one pass (no need to call it three times for each property) and I remind you that this is supposed to do a global job, without the need of individually picking an entity.
HTH
-- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
This says that chgattxtlaystyle is an unknown command but since you can use it I assume it will work. Also where you say replacement_layer and replacement_style, should I be replacing a temp value in the program where you do a table search and put my style and layer? My old Layer is: G-Anno and the new layer is G-Anno-Text. My old style is RWS and the new style is DIM. Can you re-code this. Bob
Hi, Try the next function. It changes the layer and the text style for text and attribute definitions. If a block is inserted more than one time, all instances will be updated. It will ignore Xrefs, anonymous blocks and dimensions, and it should be called like this: (CHGATTXTLAYSTYLE replacement_layer replacement_style) where replacement_layer is the name of the new layer as string and replacement_style is the name of the new text style, as string. If the layer or the style do not exist, an error alert will pop up. I Hope is what you need. ;;;======================================== (defun chgattxtlaystyle (layer txtstyle / index item) (vl-load-com) (command "_.undo" "_begin") (if (tblsearch "layer" layer) (if (tblsearch "style" txtstyle) (vlax-for block (vla-get-blocks (vla-get-activedocument(vlax-get-acad-object)) ) (if (and (= (vla-get-isXref block) :vlax-false) (wcmatch (vla-get-name block) "~`**") (wcmatch (vla-get-name block) "*Dimension") ) (progn (setq index (vla-get-count block)) (repeat index (setq item (vla-item blockdef (1- index))) (if (wcmatch (vla-get-objectname item) "AcDbAttributeDefinition,AcDbText" ) (progn (vla-put-layer item layer) (vla-put-stylename item txtstyle) (vl-cmdf "_.attsync" "_n" (vla-get-name block)) ) ) (setq index (1- index)) ) ) ) ) (alert (strcat "Style "(strcase txtstyle)" dosen't exist.") ) ) (alert (strcat "Layer "(strcase layer)" dosen't exist.") ) ) (command "_.undo" "_end") (princ) ) ;;;======================================== -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
If yu have somehting that will address the attributes and change the layer and style that would be great. Yes this is very possible. but when you say text do you mean "text attributes" ? I ask because in my opinion it is difficult to search through blocks for text and much easier to do this if you have an attribute tag. And as far as i know you would have to re-block the specified block in order to change the text. - this is why attributes are so beautiful. - :D
|
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 24, 2009 10:09 AM
in response to: Some Buddy
|
|
|
Maybe your right I am missing something. I know how the defun works, however, the reason I did that was because I was getting error readings with this: no function definition: CHGATTXTLAYSTYLE. Also the att_prop had to have aspace in front of it to work as well. When I fixed that it allowed me to pick them one at a time and did it. So that is good. But the CHGATTXTLAYSTYLE does not seem to do anything at all. Somewhere you were defining this as a function, but I don;t see where and how it gets applied. (defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0)) is suppose to do a one all pass, correct. When I load your other program for defining the chgattxtlaystyle function I get" to many arguments" For now I can at least convert them one at a time. I really appreciate the time and patience you have had with this. Bob
It seems to me that you are a little bit lost, but I will try to shed some light on this. The function I gave you is kind of a kernel and you can embed it in your code. The function is supposed to do a global job if used correctly. It uses the ActiveX approach, instead of the DXF approach. The message "unknown command " comes from the fact that you are trying to call my function as a command, which it's not. What I gave you, was defined as a function, not as a command. The difference is the c: placed in the name assigned by (defun ... : (defun C:CHA defines a command which can be called by the name: Command: CHA and will work, but (defun chgattxtlaystyle
defines a function that can not be called directly by the name, but rather in brackets, the same way you use the function (att_prop ... and of course, taking care to pass the right parameters. As for the oblique angle, in the original post you didn't say anything about it but if you want to change this too, use the attached new function. If you want to use the DXF approach, the code for the oblique angle is 51. And since the angle is a numerical value, you don't have to complicate your life passing it as string, but rather as a numerical value. This will spare you the code to convert it to a numerical value. Also note that you don't need to create variables in order to pass the information to a function, and it is possible to pass the necessary information directly, so instead of: 1st cha (defun C:CHA ( / att_layername att_stylename att-oblq att_tagname ent) (setq att_layername "G-Anno-Text") (setq att_stylename "dim") (setq att-oblq 0) (setq att_tagname "EQP") (setq ent (car (entsel))) (att_prop att_tagname ent 8 att_layername) (att_prop att_tagname ent 7 att_stylename) (att_prop att_tagname ent 51 att-oblq) (princ) )
you can use the next one: 2nd cha (defun C:CHA ( / ent) (setq ent (car (entsel))) (att_prop "EQP" ent 8 "G-Anno-Text") (att_prop "EQP" ent 7 "dim") (att_prop "EQP" ent 51 0) (princ ) ) which is smaller and faster. If you want to try my function, than you should call it like this:
(chgattxtlaystyle "G-Anno-Text" "dim" 0)
where the first argument is the new layer name, the second argument is the new style name and the third argument is the new oblique angle. If you want to used as a command, you could define a command:
(defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0))
As you can see, it will do all the replacements in one pass (no need to call it three times for each property) and I remind you that this is supposed to do a global job, without the need of individually picking an entity.
HTH
-- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
This says that chgattxtlaystyle is an unknown command but since you can use it I assume it will work. Also where you say replacement_layer and replacement_style, should I be replacing a temp value in the program where you do a table search and put my style and layer? My old Layer is: G-Anno and the new layer is G-Anno-Text. My old style is RWS and the new style is DIM. Can you re-code this. Bob
Hi, Try the next function. It changes the layer and the text style for text and attribute definitions. If a block is inserted more than one time, all instances will be updated. It will ignore Xrefs, anonymous blocks and dimensions, and it should be called like this: (CHGATTXTLAYSTYLE replacement_layer replacement_style) where replacement_layer is the name of the new layer as string and replacement_style is the name of the new text style, as string. If the layer or the style do not exist, an error alert will pop up. I Hope is what you need. ;;;======================================== (defun chgattxtlaystyle (layer txtstyle / index item) (vl-load-com) (command "_.undo" "_begin") (if (tblsearch "layer" layer) (if (tblsearch "style" txtstyle) (vlax-for block (vla-get-blocks (vla-get-activedocument(vlax-get-acad-object)) ) (if (and (= (vla-get-isXref block) :vlax-false) (wcmatch (vla-get-name block) "~`**") (wcmatch (vla-get-name block) "*Dimension") ) (progn (setq index (vla-get-count block)) (repeat index (setq item (vla-item blockdef (1- index))) (if (wcmatch (vla-get-objectname item) "AcDbAttributeDefinition,AcDbText" ) (progn (vla-put-layer item layer) (vla-put-stylename item txtstyle) (vl-cmdf "_.attsync" "_n" (vla-get-name block)) ) ) (setq index (1- index)) ) ) ) ) (alert (strcat "Style "(strcase txtstyle)" dosen't exist.") ) ) (alert (strcat "Layer "(strcase layer)" dosen't exist.") ) ) (command "_.undo" "_end") (princ) ) ;;;======================================== -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
If yu have somehting that will address the attributes and change the layer and style that would be great. Yes this is very possible. but when you say text do you mean "text attributes" ? I ask because in my opinion it is difficult to search through blocks for text and much easier to do this if you have an attribute tag. And as far as i know you would have to re-block the specified block in order to change the text. - this is why attributes are so beautiful. - :D
|
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 24, 2009 10:14 AM
in response to: BIM is in
|
|
|
Sorry didn't load your attached file. However when I loaded it nothing happened when I ran the (defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0)) So in this order.. Your function chgattxtlaystyle loaded then (defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0)) Nothing happened.
Maybe your right I am missing something. I know how the defun works, however, the reason I did that was because I was getting error readings with this: no function definition: CHGATTXTLAYSTYLE.
Also the att_prop had to have aspace in front of it to work as well. When I fixed that it allowed me to pick them one at a time and did it. So that is good. But the CHGATTXTLAYSTYLE does not seem to do anything at all. Somewhere you were defining this as a function, but I don;t see where and how it gets applied. (defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0)) is suppose to do a one all pass, correct. When I load your other program for defining the chgattxtlaystyle function I get" to many arguments" For now I can at least convert them one at a time. I really appreciate the time and patience you have had with this. Bob
It seems to me that you are a little bit lost, but I will try to shed some light on this. The function I gave you is kind of a kernel and you can embed it in your code. The function is supposed to do a global job if used correctly. It uses the ActiveX approach, instead of the DXF approach. The message "unknown command " comes from the fact that you are trying to call my function as a command, which it's not. What I gave you, was defined as a function, not as a command. The difference is the c: placed in the name assigned by (defun ... : (defun C:CHA defines a command which can be called by the name: Command: CHA and will work, but (defun chgattxtlaystyle
defines a function that can not be called directly by the name, but rather in brackets, the same way you use the function (att_prop ... and of course, taking care to pass the right parameters. As for the oblique angle, in the original post you didn't say anything about it but if you want to change this too, use the attached new function. If you want to use the DXF approach, the code for the oblique angle is 51. And since the angle is a numerical value, you don't have to complicate your life passing it as string, but rather as a numerical value. This will spare you the code to convert it to a numerical value. Also note that you don't need to create variables in order to pass the information to a function, and it is possible to pass the necessary information directly, so instead of: 1st cha (defun C:CHA ( / att_layername att_stylename att-oblq att_tagname ent) (setq att_layername "G-Anno-Text") (setq att_stylename "dim") (setq att-oblq 0) (setq att_tagname "EQP") (setq ent (car (entsel))) (att_prop att_tagname ent 8 att_layername) (att_prop att_tagname ent 7 att_stylename) (att_prop att_tagname ent 51 att-oblq) (princ) )
you can use the next one: 2nd cha (defun C:CHA ( / ent) (setq ent (car (entsel))) (att_prop "EQP" ent 8 "G-Anno-Text") (att_prop "EQP" ent 7 "dim") (att_prop "EQP" ent 51 0) (princ ) ) which is smaller and faster. If you want to try my function, than you should call it like this:
(chgattxtlaystyle "G-Anno-Text" "dim" 0)
where the first argument is the new layer name, the second argument is the new style name and the third argument is the new oblique angle. If you want to used as a command, you could define a command:
(defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0))
As you can see, it will do all the replacements in one pass (no need to call it three times for each property) and I remind you that this is supposed to do a global job, without the need of individually picking an entity.
HTH
-- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
This says that chgattxtlaystyle is an unknown command but since you can use it I assume it will work. Also where you say replacement_layer and replacement_style, should I be replacing a temp value in the program where you do a table search and put my style and layer? My old Layer is: G-Anno and the new layer is G-Anno-Text. My old style is RWS and the new style is DIM. Can you re-code this. Bob
Hi, Try the next function. It changes the layer and the text style for text and attribute definitions. If a block is inserted more than one time, all instances will be updated. It will ignore Xrefs, anonymous blocks and dimensions, and it should be called like this: (CHGATTXTLAYSTYLE replacement_layer replacement_style) where replacement_layer is the name of the new layer as string and replacement_style is the name of the new text style, as string. If the layer or the style do not exist, an error alert will pop up. I Hope is what you need. ;;;======================================== (defun chgattxtlaystyle (layer txtstyle / index item) (vl-load-com) (command "_.undo" "_begin") (if (tblsearch "layer" layer) (if (tblsearch "style" txtstyle) (vlax-for block (vla-get-blocks (vla-get-activedocument(vlax-get-acad-object)) ) (if (and (= (vla-get-isXref block) :vlax-false) (wcmatch (vla-get-name block) "~`**") (wcmatch (vla-get-name block) "*Dimension") ) (progn (setq index (vla-get-count block)) (repeat index (setq item (vla-item blockdef (1- index))) (if (wcmatch (vla-get-objectname item) "AcDbAttributeDefinition,AcDbText" ) (progn (vla-put-layer item layer) (vla-put-stylename item txtstyle) (vl-cmdf "_.attsync" "_n" (vla-get-name block)) ) ) (setq index (1- index)) ) ) ) ) (alert (strcat "Style "(strcase txtstyle)" dosen't exist.") ) ) (alert (strcat "Layer "(strcase layer)" dosen't exist.") ) ) (command "_.undo" "_end") (princ) ) ;;;======================================== -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
If yu have somehting that will address the attributes and change the layer and style that would be great. Yes this is very possible. but when you say text do you mean "text attributes" ? I ask because in my opinion it is difficult to search through blocks for text and much easier to do this if you have an attribute tag. And as far as i know you would have to re-block the specified block in order to change the text. - this is why attributes are so beautiful. - :D
|
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 24, 2009 1:25 PM
in response to: BIM is in
|
|
|
You just have to call it after you defined it. Just creating a command doesn't necessarily run it. So you still have to call it: Command: CHA -> Enter -> Than it should do something. -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
Sorry didn't load your attached file. However when I loaded it nothing happened when I ran the (defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0)) So in this order.. Your function chgattxtlaystyle loaded then (defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0)) Nothing happened.
Maybe your right I am missing something. I know how the defun works, however, the reason I did that was because I was getting error readings with this: no function definition: CHGATTXTLAYSTYLE. Also the att_prop had to have aspace in front of it to work as well. When I fixed that it allowed me to pick them one at a time and did it. So that is good. But the CHGATTXTLAYSTYLE does not seem to do anything at all. Somewhere you were defining this as a function, but I don;t see where and how it gets applied. (defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0)) is suppose to do a one all pass, correct. When I load your other program for defining the chgattxtlaystyle function I get" to many arguments" For now I can at least convert them one at a time. I really appreciate the time and patience you have had with this. Bob
It seems to me that you are a little bit lost, but I will try to shed some light on this. The function I gave you is kind of a kernel and you can embed it in your code. The function is supposed to do a global job if used correctly. It uses the ActiveX approach, instead of the DXF approach. The message "unknown command " comes from the fact that you are trying to call my function as a command, which it's not. What I gave you, was defined as a function, not as a command. The difference is the c: placed in the name assigned by (defun ... : (defun C:CHA defines a command which can be called by the name: Command: CHA and will work, but (defun chgattxtlaystyle
defines a function that can not be called directly by the name, but rather in brackets, the same way you use the function (att_prop ... and of course, taking care to pass the right parameters. As for the oblique angle, in the original post you didn't say anything about it but if you want to change this too, use the attached new function. If you want to use the DXF approach, the code for the oblique angle is 51. And since the angle is a numerical value, you don't have to complicate your life passing it as string, but rather as a numerical value. This will spare you the code to convert it to a numerical value. Also note that you don't need to create variables in order to pass the information to a function, and it is possible to pass the necessary information directly, so instead of: 1st cha (defun C:CHA ( / att_layername att_stylename att-oblq att_tagname ent) (setq att_layername "G-Anno-Text") (setq att_stylename "dim") (setq att-oblq 0) (setq att_tagname "EQP") (setq ent (car (entsel))) (att_prop att_tagname ent 8 att_layername) (att_prop att_tagname ent 7 att_stylename) (att_prop att_tagname ent 51 att-oblq) (princ) )
you can use the next one: 2nd cha (defun C:CHA ( / ent) (setq ent (car (entsel))) (att_prop "EQP" ent 8 "G-Anno-Text") (att_prop "EQP" ent 7 "dim") (att_prop "EQP" ent 51 0) (princ ) ) which is smaller and faster. If you want to try my function, than you should call it like this:
(chgattxtlaystyle "G-Anno-Text" "dim" 0)
where the first argument is the new layer name, the second argument is the new style name and the third argument is the new oblique angle. If you want to used as a command, you could define a command:
(defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0))
As you can see, it will do all the replacements in one pass (no need to call it three times for each property) and I remind you that this is supposed to do a global job, without the need of individually picking an entity.
HTH
-- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
This says that chgattxtlaystyle is an unknown command but since you can use it I assume it will work. Also where you say replacement_layer and replacement_style, should I be replacing a temp value in the program where you do a table search and put my style and layer? My old Layer is: G-Anno and the new layer is G-Anno-Text. My old style is RWS and the new style is DIM. Can you re-code this. Bob
Hi, Try the next function. It changes the layer and the text style for text and attribute definitions. If a block is inserted more than one time, all instances will be updated. It will ignore Xrefs, anonymous blocks and dimensions, and it should be called like this: (CHGATTXTLAYSTYLE replacement_layer replacement_style) where replacement_layer is the name of the new layer as string and replacement_style is the name of the new text style, as string. If the layer or the style do not exist, an error alert will pop up. I Hope is what you need. ;;;======================================== (defun chgattxtlaystyle (layer txtstyle / index item) (vl-load-com) (command "_.undo" "_begin") (if (tblsearch "layer" layer) (if (tblsearch "style" txtstyle) (vlax-for block (vla-get-blocks (vla-get-activedocument(vlax-get-acad-object)) ) (if (and (= (vla-get-isXref block) :vlax-false) (wcmatch (vla-get-name block) "~`**") (wcmatch (vla-get-name block) "*Dimension") ) (progn (setq index (vla-get-count block)) (repeat index (setq item (vla-item blockdef (1- index))) (if (wcmatch (vla-get-objectname item) "AcDbAttributeDefinition,AcDbText" ) (progn (vla-put-layer item layer) (vla-put-stylename item txtstyle) (vl-cmdf "_.attsync" "_n" (vla-get-name block)) ) ) (setq index (1- index)) ) ) ) ) (alert (strcat "Style "(strcase txtstyle)" dosen't exist.") ) ) (alert (strcat "Layer "(strcase layer)" dosen't exist.") ) ) (command "_.undo" "_end") (princ) ) ;;;======================================== -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
If yu have somehting that will address the attributes and change the layer and style that would be great. Yes this is very possible. but when you say text do you mean "text attributes" ? I ask because in my opinion it is difficult to search through blocks for text and much easier to do this if you have an attribute tag. And as far as i know you would have to re-block the specified block in order to change the text. - this is why attributes are so beautiful. - :D
|
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 24, 2009 1:33 PM
in response to: BIM is in
|
|
|
<att_prop had to have aspace in front of it to work as well> This makes no sense, believe me. I'm programming in LISP for almost 15 years and I've never heard such thing. The LISP interpretor simply ignores the spaces, so the expression ( setq a (car ( list 1 2 3) ) ) is th esame as (setq a (car(list 1 2 3))) -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
Maybe your right I am missing something. I know how the defun works, however, the reason I did that was because I was getting error readings with this: no function definition: CHGATTXTLAYSTYLE.
Also the att_prop had to have aspace in front of it to work as well. When I fixed that it allowed me to pick them one at a time and did it. So that is good. But the CHGATTXTLAYSTYLE does not seem to do anything at all. Somewhere you were defining this as a function, but I don;t see where and how it gets applied. (defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0)) is suppose to do a one all pass, correct. When I load your other program for defining the chgattxtlaystyle function I get" to many arguments" For now I can at least convert them one at a time. I really appreciate the time and patience you have had with this. Bob
It seems to me that you are a little bit lost, but I will try to shed some light on this. The function I gave you is kind of a kernel and you can embed it in your code. The function is supposed to do a global job if used correctly. It uses the ActiveX approach, instead of the DXF approach. The message "unknown command " comes from the fact that you are trying to call my function as a command, which it's not. What I gave you, was defined as a function, not as a command. The difference is the c: placed in the name assigned by (defun ... : (defun C:CHA defines a command which can be called by the name: Command: CHA and will work, but (defun chgattxtlaystyle
defines a function that can not be called directly by the name, but rather in brackets, the same way you use the function (att_prop ... and of course, taking care to pass the right parameters. As for the oblique angle, in the original post you didn't say anything about it but if you want to change this too, use the attached new function. If you want to use the DXF approach, the code for the oblique angle is 51. And since the angle is a numerical value, you don't have to complicate your life passing it as string, but rather as a numerical value. This will spare you the code to convert it to a numerical value. Also note that you don't need to create variables in order to pass the information to a function, and it is possible to pass the necessary information directly, so instead of: 1st cha (defun C:CHA ( / att_layername att_stylename att-oblq att_tagname ent) (setq att_layername "G-Anno-Text") (setq att_stylename "dim") (setq att-oblq 0) (setq att_tagname "EQP") (setq ent (car (entsel))) (att_prop att_tagname ent 8 att_layername) (att_prop att_tagname ent 7 att_stylename) (att_prop att_tagname ent 51 att-oblq) (princ) )
you can use the next one: 2nd cha (defun C:CHA ( / ent) (setq ent (car (entsel))) (att_prop "EQP" ent 8 "G-Anno-Text") (att_prop "EQP" ent 7 "dim") (att_prop "EQP" ent 51 0) (princ ) ) which is smaller and faster. If you want to try my function, than you should call it like this:
(chgattxtlaystyle "G-Anno-Text" "dim" 0)
where the first argument is the new layer name, the second argument is the new style name and the third argument is the new oblique angle. If you want to used as a command, you could define a command:
(defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0))
As you can see, it will do all the replacements in one pass (no need to call it three times for each property) and I remind you that this is supposed to do a global job, without the need of individually picking an entity.
HTH
-- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
This says that chgattxtlaystyle is an unknown command but since you can use it I assume it will work. Also where you say replacement_layer and replacement_style, should I be replacing a temp value in the program where you do a table search and put my style and layer? My old Layer is: G-Anno and the new layer is G-Anno-Text. My old style is RWS and the new style is DIM. Can you re-code this. Bob
Hi, Try the next function. It changes the layer and the text style for text and attribute definitions. If a block is inserted more than one time, all instances will be updated. It will ignore Xrefs, anonymous blocks and dimensions, and it should be called like this: (CHGATTXTLAYSTYLE replacement_layer replacement_style) where replacement_layer is the name of the new layer as string and replacement_style is the name of the new text style, as string. If the layer or the style do not exist, an error alert will pop up. I Hope is what you need. ;;;======================================== (defun chgattxtlaystyle (layer txtstyle / index item) (vl-load-com) (command "_.undo" "_begin") (if (tblsearch "layer" layer) (if (tblsearch "style" txtstyle) (vlax-for block (vla-get-blocks (vla-get-activedocument(vlax-get-acad-object)) ) (if (and (= (vla-get-isXref block) :vlax-false) (wcmatch (vla-get-name block) "~`**") (wcmatch (vla-get-name block) "*Dimension") ) (progn (setq index (vla-get-count block)) (repeat index (setq item (vla-item blockdef (1- index))) (if (wcmatch (vla-get-objectname item) "AcDbAttributeDefinition,AcDbText" ) (progn (vla-put-layer item layer) (vla-put-stylename item txtstyle) (vl-cmdf "_.attsync" "_n" (vla-get-name block)) ) ) (setq index (1- index)) ) ) ) ) (alert (strcat "Style "(strcase txtstyle)" dosen't exist.") ) ) (alert (strcat "Layer "(strcase layer)" dosen't exist.") ) ) (command "_.undo" "_end") (princ) ) ;;;======================================== -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
If yu have somehting that will address the attributes and change the layer and style that would be great. Yes this is very possible. but when you say text do you mean "text attributes" ? I ask because in my opinion it is difficult to search through blocks for text and much easier to do this if you have an attribute tag. And as far as i know you would have to re-block the specified block in order to change the text. - this is why attributes are so beautiful. - :D
|
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 24, 2009 11:55 PM
in response to: Some Buddy
|
|
|
I too have been programming as well as long as you. But I do admit you are beyond me in may areas, which i do not venture into if I don't have to. I always ty to keep my programming simple if possible, It's good that there are others like you which is why I am seeking help. I don't do it as often as I should. In either case I am feeding you valid info. I know the cha command needs to be issued. I also agree with you about the space, but it didnt do anything untill i noticed in your previous post you had the space. So I put it in and it works. I don't know, just know it did. HA! Also can you reply to me email format and give me your info to put in the routine. It's your credit. I still need to keep tweaking it till I get to run on its own when a drawing opens up. I will need to address straight text in the block as well. All I can do it pick away at it and ask for help. If you would lke to continue to help I would greatly appreciate it. I think this is something many can use. Bob
<att_prop had to have aspace in front of it to work as well> This makes no sense, believe me. I'm programming in LISP for almost 15 years and I've never heard such thing. The LISP interpretor simply ignores the spaces, so the expression ( setq a (car ( list 1 2 3) ) ) is th esame as (setq a (car(list 1 2 3))) -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
Maybe your right I am missing something. I know how the defun works, however, the reason I did that was because I was getting error readings with this: no function definition: CHGATTXTLAYSTYLE. Also the att_prop had to have aspace in front of it to work as well. When I fixed that it allowed me to pick them one at a time and did it. So that is good. But the CHGATTXTLAYSTYLE does not seem to do anything at all. Somewhere you were defining this as a function, but I don;t see where and how it gets applied. (defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0)) is suppose to do a one all pass, correct. When I load your other program for defining the chgattxtlaystyle function I get" to many arguments" For now I can at least convert them one at a time. I really appreciate the time and patience you have had with this. Bob
It seems to me that you are a little bit lost, but I will try to shed some light on this. The function I gave you is kind of a kernel and you can embed it in your code. The function is supposed to do a global job if used correctly. It uses the ActiveX approach, instead of the DXF approach. The message "unknown command " comes from the fact that you are trying to call my function as a command, which it's not. What I gave you, was defined as a function, not as a command. The difference is the c: placed in the name assigned by (defun ... : (defun C:CHA defines a command which can be called by the name: Command: CHA and will work, but (defun chgattxtlaystyle
defines a function that can not be called directly by the name, but rather in brackets, the same way you use the function (att_prop ... and of course, taking care to pass the right parameters. As for the oblique angle, in the original post you didn't say anything about it but if you want to change this too, use the attached new function. If you want to use the DXF approach, the code for the oblique angle is 51. And since the angle is a numerical value, you don't have to complicate your life passing it as string, but rather as a numerical value. This will spare you the code to convert it to a numerical value. Also note that you don't need to create variables in order to pass the information to a function, and it is possible to pass the necessary information directly, so instead of: 1st cha (defun C:CHA ( / att_layername att_stylename att-oblq att_tagname ent) (setq att_layername "G-Anno-Text") (setq att_stylename "dim") (setq att-oblq 0) (setq att_tagname "EQP") (setq ent (car (entsel))) (att_prop att_tagname ent 8 att_layername) (att_prop att_tagname ent 7 att_stylename) (att_prop att_tagname ent 51 att-oblq) (princ) )
you can use the next one: 2nd cha (defun C:CHA ( / ent) (setq ent (car (entsel))) (att_prop "EQP" ent 8 "G-Anno-Text") (att_prop "EQP" ent 7 "dim") (att_prop "EQP" ent 51 0) (princ ) ) which is smaller and faster. If you want to try my function, than you should call it like this:
(chgattxtlaystyle "G-Anno-Text" "dim" 0)
where the first argument is the new layer name, the second argument is the new style name and the third argument is the new oblique angle. If you want to used as a command, you could define a command:
(defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0))
As you can see, it will do all the replacements in one pass (no need to call it three times for each property) and I remind you that this is supposed to do a global job, without the need of individually picking an entity.
HTH
-- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
This says that chgattxtlaystyle is an unknown command but since you can use it I assume it will work. Also where you say replacement_layer and replacement_style, should I be replacing a temp value in the program where you do a table search and put my style and layer? My old Layer is: G-Anno and the new layer is G-Anno-Text. My old style is RWS and the new style is DIM. Can you re-code this. Bob
Hi, Try the next function. It changes the layer and the text style for text and attribute definitions. If a block is inserted more than one time, all instances will be updated. It will ignore Xrefs, anonymous blocks and dimensions, and it should be called like this: (CHGATTXTLAYSTYLE replacement_layer replacement_style) where replacement_layer is the name of the new layer as string and replacement_style is the name of the new text style, as string. If the layer or the style do not exist, an error alert will pop up. I Hope is what you need. ;;;======================================== (defun chgattxtlaystyle (layer txtstyle / index item) (vl-load-com) (command "_.undo" "_begin") (if (tblsearch "layer" layer) (if (tblsearch "style" txtstyle) (vlax-for block (vla-get-blocks (vla-get-activedocument(vlax-get-acad-object)) ) (if (and (= (vla-get-isXref block) :vlax-false) (wcmatch (vla-get-name block) "~`**") (wcmatch (vla-get-name block) "*Dimension") ) (progn (setq index (vla-get-count block)) (repeat index (setq item (vla-item blockdef (1- index))) (if (wcmatch (vla-get-objectname item) "AcDbAttributeDefinition,AcDbText" ) (progn (vla-put-layer item layer) (vla-put-stylename item txtstyle) (vl-cmdf "_.attsync" "_n" (vla-get-name block)) ) ) (setq index (1- index)) ) ) ) ) (alert (strcat "Style "(strcase txtstyle)" dosen't exist.") ) ) (alert (strcat "Layer "(strcase layer)" dosen't exist.") ) ) (command "_.undo" "_end") (princ) ) ;;;======================================== -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
If yu have somehting that will address the attributes and change the layer and style that would be great. Yes this is very possible. but when you say text do you mean "text attributes" ? I ask because in my opinion it is difficult to search through blocks for text and much easier to do this if you have an attribute tag. And as far as i know you would have to re-block the specified block in order to change the text. - this is why attributes are so beautiful. - :D
|
|
|
|
|
|
|
|
|
Re: HELP NEEDED: Blocks with Attributes and/or Text in them
Posted:
Mar 25, 2009 1:00 PM
in response to: BIM is in
|
|
|
Whatever space was in front of att_prop in my post, it's because of some copy-paste. I would never do something like this or try to solve a bug like this. The fact that after you inserted a space your code worked it's a pure coincidence and the explanation should be somewhere else. Finally I don't understand if it works for you or not. If not, just post a little drawing so I could make some tests when I have time. I tested my code here on some random text, but maybe you have some particular situation. If your drawing is not uploading, zip it. -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
I too have been programming as well as long as you. But I do admit you are beyond me in may areas, which i do not venture into if I don't have to. I always ty to keep my programming simple if possible, It's good that there are others like you which is why I am seeking help. I don't do it as often as I should. In either case I am feeding you valid info. I know the cha command needs to be issued. I also agree with you about the space, but it didnt do anything untill i noticed in your previous post you had the space. So I put it in and it works. I don't know, just know it did. HA! Also can you reply to me email format and give me your info to put in the routine. It's your credit. I still need to keep tweaking it till I get to run on its own when a drawing opens up. I will need to address straight text in the block as well. All I can do it pick away at it and ask for help. If you would lke to continue to help I would greatly appreciate it. I think this is something many can use. Bob
<att_prop had to have aspace in front of it to work as well> This makes no sense, believe me. I'm programming in LISP for almost 15 years and I've never heard such thing. The LISP interpretor simply ignores the spaces, so the expression ( setq a (car ( list 1 2 3) ) ) is th esame as (setq a (car(list 1 2 3))) -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
Maybe your right I am missing something. I know how the defun works, however, the reason I did that was because I was getting error readings with this: no function definition: CHGATTXTLAYSTYLE. Also the att_prop had to have aspace in front of it to work as well. When I fixed that it allowed me to pick them one at a time and did it. So that is good. But the CHGATTXTLAYSTYLE does not seem to do anything at all. Somewhere you were defining this as a function, but I don;t see where and how it gets applied. (defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0)) is suppose to do a one all pass, correct. When I load your other program for defining the chgattxtlaystyle function I get" to many arguments" For now I can at least convert them one at a time. I really appreciate the time and patience you have had with this. Bob
It seems to me that you are a little bit lost, but I will try to shed some light on this. The function I gave you is kind of a kernel and you can embed it in your code. The function is supposed to do a global job if used correctly. It uses the ActiveX approach, instead of the DXF approach. The message "unknown command " comes from the fact that you are trying to call my function as a command, which it's not. What I gave you, was defined as a function, not as a command. The difference is the c: placed in the name assigned by (defun ... : (defun C:CHA defines a command which can be called by the name: Command: CHA and will work, but (defun chgattxtlaystyle
defines a function that can not be called directly by the name, but rather in brackets, the same way you use the function (att_prop ... and of course, taking care to pass the right parameters. As for the oblique angle, in the original post you didn't say anything about it but if you want to change this too, use the attached new function. If you want to use the DXF approach, the code for the oblique angle is 51. And since the angle is a numerical value, you don't have to complicate your life passing it as string, but rather as a numerical value. This will spare you the code to convert it to a numerical value. Also note that you don't need to create variables in order to pass the information to a function, and it is possible to pass the necessary information directly, so instead of: 1st cha (defun C:CHA ( / att_layername att_stylename att-oblq att_tagname ent) (setq att_layername "G-Anno-Text") (setq att_stylename "dim") (setq att-oblq 0) (setq att_tagname "EQP") (setq ent (car (entsel))) (att_prop att_tagname ent 8 att_layername) (att_prop att_tagname ent 7 att_stylename) (att_prop att_tagname ent 51 att-oblq) (princ) )
you can use the next one: 2nd cha (defun C:CHA ( / ent) (setq ent (car (entsel))) (att_prop "EQP" ent 8 "G-Anno-Text") (att_prop "EQP" ent 7 "dim") (att_prop "EQP" ent 51 0) (princ ) ) which is smaller and faster. If you want to try my function, than you should call it like this:
(chgattxtlaystyle "G-Anno-Text" "dim" 0)
where the first argument is the new layer name, the second argument is the new style name and the third argument is the new oblique angle. If you want to used as a command, you could define a command:
(defun C:CHA () (chgattxtlaystyle "G-Anno-Text" "dim" 0))
As you can see, it will do all the replacements in one pass (no need to call it three times for each property) and I remind you that this is supposed to do a global job, without the need of individually picking an entity.
HTH
-- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
This says that chgattxtlaystyle is an unknown command but since you can use it I assume it will work. Also where you say replacement_layer and replacement_style, should I be replacing a temp value in the program where you do a table search and put my style and layer? My old Layer is: G-Anno and the new layer is G-Anno-Text. My old style is RWS and the new style is DIM. Can you re-code this. Bob
Hi, Try the next function. It changes the layer and the text style for text and attribute definitions. If a block is inserted more than one time, all instances will be updated. It will ignore Xrefs, anonymous blocks and dimensions, and it should be called like this: (CHGATTXTLAYSTYLE replacement_layer replacement_style) where replacement_layer is the name of the new layer as string and replacement_style is the name of the new text style, as string. If the layer or the style do not exist, an error alert will pop up. I Hope is what you need. ;;;======================================== (defun chgattxtlaystyle (layer txtstyle / index item) (vl-load-com) (command "_.undo" "_begin") (if (tblsearch "layer" layer) (if (tblsearch "style" txtstyle) (vlax-for block (vla-get-blocks (vla-get-activedocument(vlax-get-acad-object)) ) (if (and (= (vla-get-isXref block) :vlax-false) (wcmatch (vla-get-name block) "~`**") (wcmatch (vla-get-name block) "*Dimension") ) (progn (setq index (vla-get-count block)) (repeat index (setq item (vla-item blockdef (1- index))) (if (wcmatch (vla-get-objectname item) "AcDbAttributeDefinition,AcDbText" ) (progn (vla-put-layer item layer) (vla-put-stylename item txtstyle) (vl-cmdf "_.attsync" "_n" (vla-get-name block)) ) ) (setq index (1- index)) ) ) ) ) (alert (strcat "Style "(strcase txtstyle)" dosen't exist.") ) ) (alert (strcat "Layer "(strcase layer)" dosen't exist.") ) ) (command "_.undo" "_end") (princ) ) ;;;======================================== -- Humans are born with a wide horizon. As time goes by, the horizon narrows and narrows, until it becomes a point of view.
If yu have somehting that will address the attributes and change the layer and style that would be great. Yes this is very possible. but when you say text do you mean "text attributes" ? I ask because in my opinion it is difficult to search through blocks for text and much easier to do this if you have an attribute tag. And as far as i know you would have to re-block the specified block in order to change the text. - this is why attributes are so beautiful. - :D
|
|
|
|
|
|