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

Script to change block layer and set to no plot

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
tevansHMH
811 Views, 12 Replies

Script to change block layer and set to no plot

tevansHMH
Advocate
Advocate

I have written this script to change a block to another layer, freeze that layer and set it to noplot but it isnt working. can anyone tell me where it is broken?

 

;;SCRIPT TO SUBSTITUTE A BLOCK and CHANGES ITS LAYER, FREEZE AND SET TO NO PLOT
;;THE SOURCE BLOCK MAY EXIST IN MANY
;;PLACES IN THE DRAWING, ALL INSTANCES
;;WILL BE REPLACED.
;;BY TED EVANS 7-22-21
;;
ATTDIA 0
ATTREQ 0
_-Layer
_set 0

(command"_.chprop"(ssget"_X"'((2."soffit_vent")));"" "_layer" "A-roof-vent" "")
-INSERT
"sofit_vent=s:\cad\projects\autocad\configuration\blocks\arch\soffit_vent"
0,0,0
1
0
ERASE l
(SETQ en (ENTLAST))

-LAYER
p
n
*a-roof-vent
s 0 f "*a-roof-vent"

zoom
e
ATTDIA 1
ATTREQ 1
;END ------------------------

0 Likes

Script to change block layer and set to no plot

I have written this script to change a block to another layer, freeze that layer and set it to noplot but it isnt working. can anyone tell me where it is broken?

 

;;SCRIPT TO SUBSTITUTE A BLOCK and CHANGES ITS LAYER, FREEZE AND SET TO NO PLOT
;;THE SOURCE BLOCK MAY EXIST IN MANY
;;PLACES IN THE DRAWING, ALL INSTANCES
;;WILL BE REPLACED.
;;BY TED EVANS 7-22-21
;;
ATTDIA 0
ATTREQ 0
_-Layer
_set 0

(command"_.chprop"(ssget"_X"'((2."soffit_vent")));"" "_layer" "A-roof-vent" "")
-INSERT
"sofit_vent=s:\cad\projects\autocad\configuration\blocks\arch\soffit_vent"
0,0,0
1
0
ERASE l
(SETQ en (ENTLAST))

-LAYER
p
n
*a-roof-vent
s 0 f "*a-roof-vent"

zoom
e
ATTDIA 1
ATTREQ 1
;END ------------------------

Tags (1)
12 REPLIES 12
Message 2 of 13
ВeekeeCZ
in reply to: tevansHMH

ВeekeeCZ
Consultant
Consultant

It would be nice of you if you post a test drawing and the command-line listing.

0 Likes

It would be nice of you if you post a test drawing and the command-line listing.

Message 3 of 13
tevansHMH
in reply to: ВeekeeCZ

tevansHMH
Advocate
Advocate

here is a sample drawing attached and the command line listing

Command: _SCRIPT
Enter script file name <S:\CAD\Projects\Blackpoint\1266\Constructs\Roof.scr>: "S:\CAD\Projects\AutoCAD\Configuration\Common\Scripts\RoofVents.scr"

Command: ATTDIA
Enter new value for ATTDIA <0>: 0

Command: ATTREQ
Enter new value for ATTREQ <0>: 0

Command: _-Layer

Current layer: "BP-Footprint"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: _set
Enter layer name to make current or <select object>: 0
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]:

Command: (command"_.chprop"(ssget"_X"'((2."soffit_vent")));"" "_layer" "A-roof-vent" "")
(_> -INSERT
(_> "sofit_vent=s:\cad\projects\autocad\configuration\blocks\arch\soffit_vent"
(_> 0,0,0
(_> 1
(_> 0
(_> ERASE l
(_> (SETQ en (ENTLAST))
(_>
(_> -LAYER
(_> p
(_> n
(_> *a-roof-vent
(_> s 0 f "*a-roof-vent"
(_>
(_> zoom
(_> e
(_> ATTDIA 1
(_> ATTREQ 1

0 Likes

here is a sample drawing attached and the command line listing

Command: _SCRIPT
Enter script file name <S:\CAD\Projects\Blackpoint\1266\Constructs\Roof.scr>: "S:\CAD\Projects\AutoCAD\Configuration\Common\Scripts\RoofVents.scr"

Command: ATTDIA
Enter new value for ATTDIA <0>: 0

Command: ATTREQ
Enter new value for ATTREQ <0>: 0

Command: _-Layer

Current layer: "BP-Footprint"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: _set
Enter layer name to make current or <select object>: 0
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]:

Command: (command"_.chprop"(ssget"_X"'((2."soffit_vent")));"" "_layer" "A-roof-vent" "")
(_> -INSERT
(_> "sofit_vent=s:\cad\projects\autocad\configuration\blocks\arch\soffit_vent"
(_> 0,0,0
(_> 1
(_> 0
(_> ERASE l
(_> (SETQ en (ENTLAST))
(_>
(_> -LAYER
(_> p
(_> n
(_> *a-roof-vent
(_> s 0 f "*a-roof-vent"
(_>
(_> zoom
(_> e
(_> ATTDIA 1
(_> ATTREQ 1

Message 4 of 13
Kent1Cooper
in reply to: tevansHMH

Kent1Cooper
Consultant
Consultant

@tevansHMH wrote:

....

(command"_.chprop"(ssget"_X"'((2."soffit_vent")));"" "_layer" "A-roof-vent" "")
....


A semicolon is Enter in a command macro, but in a Script it "comments out" the rest of the line.  Try:

 

(command "_.chprop" (ssget "_X" '((2."soffit_vent"))) "" "_layer" "A-roof-vent" "")

 

Kent Cooper, AIA
0 Likes


@tevansHMH wrote:

....

(command"_.chprop"(ssget"_X"'((2."soffit_vent")));"" "_layer" "A-roof-vent" "")
....


A semicolon is Enter in a command macro, but in a Script it "comments out" the rest of the line.  Try:

 

(command "_.chprop" (ssget "_X" '((2."soffit_vent"))) "" "_layer" "A-roof-vent" "")

 

Kent Cooper, AIA
Message 5 of 13
tevansHMH
in reply to: Kent1Cooper

tevansHMH
Advocate
Advocate

got a little further then this

Command: _SCRIPT
Enter script file name <S:\CAD\Projects\Blackpoint\1266\Constructs\Roof.scr>: "S:\CAD\Projects\AutoCAD\Configuration\Common\Scripts\RoofVents.scr"

Command: ATTDIA
Enter new value for ATTDIA <0>: 0

Command: ATTREQ
Enter new value for ATTREQ <0>: 0

Command: _-Layer

Current layer: "BP-Footprint"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: _set
Enter layer name to make current or <select object>: 0
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]:

Command: (command"_.chprop"(ssget"_X"'((2."soffit_vent")))"" "_layer" "A-roof-vent" "")
_.chprop
Select objects: bad SSGET list
Select objects: -INSERT


*Invalid selection*
Expects a point or Window/Last/Crossing/BOX/ALL/Fence/WPolygon/CPolygon/Group/Add/Remove/Multiple/Previous/Undo/AUto/SIngle

0 Likes

got a little further then this

Command: _SCRIPT
Enter script file name <S:\CAD\Projects\Blackpoint\1266\Constructs\Roof.scr>: "S:\CAD\Projects\AutoCAD\Configuration\Common\Scripts\RoofVents.scr"

Command: ATTDIA
Enter new value for ATTDIA <0>: 0

Command: ATTREQ
Enter new value for ATTREQ <0>: 0

Command: _-Layer

Current layer: "BP-Footprint"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: _set
Enter layer name to make current or <select object>: 0
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]:

Command: (command"_.chprop"(ssget"_X"'((2."soffit_vent")))"" "_layer" "A-roof-vent" "")
_.chprop
Select objects: bad SSGET list
Select objects: -INSERT


*Invalid selection*
Expects a point or Window/Last/Crossing/BOX/ALL/Fence/WPolygon/CPolygon/Group/Add/Remove/Multiple/Previous/Undo/AUto/SIngle

Message 6 of 13
Kent1Cooper
in reply to: tevansHMH

Kent1Cooper
Consultant
Consultant

@tevansHMH wrote:

....

(command"_.chprop"(ssget"_X"'((2."soffit_vent")))"" "_layer" "A-roof-vent" "")

....


I didn't notice before, but an entity data entry with a dotted-pair list requires a space on either side of the period.  Try:

  (command"_.chprop"(ssget"_X"'((2 . "soffit_vent")))"" "_layer" "A-roof-vent" "")

 

[And just as a matter of visual clarity, I find it easier to "read" what's going on with spaces in other places where they may not be required:

  (command "_.chprop" (ssget "_X" '((2 . "soffit_vent"))) "" "_layer" "A-roof-vent" "")

especially where it's outright visually ambiguous as at the "' adjacency.  But some spaces are not optional.]

Kent Cooper, AIA
0 Likes


@tevansHMH wrote:

....

(command"_.chprop"(ssget"_X"'((2."soffit_vent")))"" "_layer" "A-roof-vent" "")

....


I didn't notice before, but an entity data entry with a dotted-pair list requires a space on either side of the period.  Try:

  (command"_.chprop"(ssget"_X"'((2 . "soffit_vent")))"" "_layer" "A-roof-vent" "")

 

[And just as a matter of visual clarity, I find it easier to "read" what's going on with spaces in other places where they may not be required:

  (command "_.chprop" (ssget "_X" '((2 . "soffit_vent"))) "" "_layer" "A-roof-vent" "")

especially where it's outright visually ambiguous as at the "' adjacency.  But some spaces are not optional.]

Kent Cooper, AIA
Message 7 of 13
tevansHMH
in reply to: Kent1Cooper

tevansHMH
Advocate
Advocate

that fixed it except the block is not being redefined when inserted to replace the existing block. what would cause that? I modified the block so the hatch is on a different layer hoping that when inserted it would redefine the block with the update.

0 Likes

that fixed it except the block is not being redefined when inserted to replace the existing block. what would cause that? I modified the block so the hatch is on a different layer hoping that when inserted it would redefine the block with the update.

Message 8 of 13
Kent1Cooper
in reply to: tevansHMH

Kent1Cooper
Consultant
Consultant

Now that what precedes that Insertion has been fixed, and it should actually be getting around to the Insert part, are you getting any message during that?

Kent Cooper, AIA
0 Likes

Now that what precedes that Insertion has been fixed, and it should actually be getting around to the Insert part, are you getting any message during that?

Kent Cooper, AIA
Message 9 of 13
tevansHMH
in reply to: Kent1Cooper

tevansHMH
Advocate
Advocate

No errors or message, seems to proceed to the end.

0 Likes

No errors or message, seems to proceed to the end.

Message 10 of 13
Kent1Cooper
in reply to: tevansHMH

Kent1Cooper
Consultant
Consultant

When I set up a similar situation, it successfully redefined the Block, and I got the message:

Block "BlockName" redefined

 

[without being asked whether I want to redefine it], and before it asks for the insertion point.  I assume you are not getting that message.  What else appears at the command line in the range of the Insert operation?

Kent Cooper, AIA
0 Likes

When I set up a similar situation, it successfully redefined the Block, and I got the message:

Block "BlockName" redefined

 

[without being asked whether I want to redefine it], and before it asks for the insertion point.  I assume you are not getting that message.  What else appears at the command line in the range of the Insert operation?

Kent Cooper, AIA
Message 11 of 13
tevansHMH
in reply to: Kent1Cooper

tevansHMH
Advocate
Advocate

Command: _SCRIPT
Enter script file name <S:\CAD\Projects\Blackpoint\1266\Constructs\Roof.scr>: "S:\CAD\Projects\AutoCAD\Configuration\Common\Scripts\RoofVents.scr"

Command: ATTDIA
Enter new value for ATTDIA <0>: 0

Command: ATTREQ
Enter new value for ATTREQ <0>: 0

Command: _-Layer

Current layer: "BP-Footprint"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: _set
Enter layer name to make current or <select object>: 0
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]:

Command: (command"_.chprop"(ssget"_X"'((2 ."soffit_vent")))"" "_layer" "A-roof-vent" "")
misplaced dot on input
Command: -INSERT
Enter block name or [?]: "sofit_vent=s:\cad\projects\autocad\configuration\blocks\arch\soffit_vent"
Duplicate definition of block _ArchTick ignored.
Duplicate definition of block DimArrow ignored.

Unit-scaling inserted database...
Units: Inches Conversion: 0'-1"
Specify insertion point or [Basepoint/Scale/Rotate]: 0,0,0
Specify scale factor <1>: 1

Specify rotation angle <0.00>: 0

Command: ERASE
Select objects: l
1 found

Select objects: (SETQ en (ENTLAST))
<Entity name: 26ea625fd30>
1 found (1 duplicate), 1 total

Select objects:

Command: -LAYER

Current layer: "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: p

Enter a plotting preference [Plot/No plot] <Plot>: n

Enter layer name(s) for this plot preference <0>: *a-roof-vent
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: s
Enter layer name to make current or <select object>: 0 Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: f
Enter name list of layer(s) to freeze or <select objects>: "*a-roof-vent"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]:

Command: zoom

Specify corner of window, enter a scale factor (nX or nXP), or
[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: e

Command: ATTDIA
Enter new value for ATTDIA <0>: 1

0 Likes

Command: _SCRIPT
Enter script file name <S:\CAD\Projects\Blackpoint\1266\Constructs\Roof.scr>: "S:\CAD\Projects\AutoCAD\Configuration\Common\Scripts\RoofVents.scr"

Command: ATTDIA
Enter new value for ATTDIA <0>: 0

Command: ATTREQ
Enter new value for ATTREQ <0>: 0

Command: _-Layer

Current layer: "BP-Footprint"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: _set
Enter layer name to make current or <select object>: 0
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]:

Command: (command"_.chprop"(ssget"_X"'((2 ."soffit_vent")))"" "_layer" "A-roof-vent" "")
misplaced dot on input
Command: -INSERT
Enter block name or [?]: "sofit_vent=s:\cad\projects\autocad\configuration\blocks\arch\soffit_vent"
Duplicate definition of block _ArchTick ignored.
Duplicate definition of block DimArrow ignored.

Unit-scaling inserted database...
Units: Inches Conversion: 0'-1"
Specify insertion point or [Basepoint/Scale/Rotate]: 0,0,0
Specify scale factor <1>: 1

Specify rotation angle <0.00>: 0

Command: ERASE
Select objects: l
1 found

Select objects: (SETQ en (ENTLAST))
<Entity name: 26ea625fd30>
1 found (1 duplicate), 1 total

Select objects:

Command: -LAYER

Current layer: "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: p

Enter a plotting preference [Plot/No plot] <Plot>: n

Enter layer name(s) for this plot preference <0>: *a-roof-vent
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: s
Enter layer name to make current or <select object>: 0 Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: f
Enter name list of layer(s) to freeze or <select objects>: "*a-roof-vent"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]:

Command: zoom

Specify corner of window, enter a scale factor (nX or nXP), or
[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: e

Command: ATTDIA
Enter new value for ATTDIA <0>: 1

Message 12 of 13
Kent1Cooper
in reply to: tevansHMH

Kent1Cooper
Consultant
Consultant
Accepted solution

@tevansHMH wrote:

....

"sofit_vent=s:\cad\projects\autocad\configuration\blocks\arch\soffit_vent"
....


[Could it be about the difference between one f and two ff's?]

Kent Cooper, AIA
0 Likes


@tevansHMH wrote:

....

"sofit_vent=s:\cad\projects\autocad\configuration\blocks\arch\soffit_vent"
....


[Could it be about the difference between one f and two ff's?]

Kent Cooper, AIA
Message 13 of 13
tevansHMH
in reply to: Kent1Cooper

tevansHMH
Advocate
Advocate

that was it. I was close, just a few little errors. Im usually not this bad at overlooking things.

Thanks for the extra set of eyes.

0 Likes

that was it. I was close, just a few little errors. Im usually not this bad at overlooking things.

Thanks for the extra set of eyes.

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report