Lisp to change some lineweights

Lisp to change some lineweights

Anonymous
Not applicable
4,326 Views
10 Replies
Message 1 of 11

Lisp to change some lineweights

Anonymous
Not applicable

 

Hello all,

 

I am new on lisp or scripts languages, so today I need your kindly help.

I have some drawings, and because of printing options, I need to change lineweights of some entities. What I need is:

 

- Select ALL entities on a drawing and change is lineweight from 0.3mm to 0.18mm

- Select ALL entities on a drawing and change is lineweight from 0.6mm to 0.3mm

- Select a layer name (ex.: dims) and change that layer lineweight to 0.13mm

- Select ALL hatch entities and change is properties, for example colour, linetype, lineweigth

- Select All entities with linetype hidden and change it to dashed

 

Can this be done on lisp? With this solution will be faster to change some drawings we received from outside, and change is properties in order we can print it with our standards.

I appreciatte your help.

Thank you.

Best regards.

 

0 Likes
4,327 Views
10 Replies
Replies (10)
Message 2 of 11

dbroad
Mentor
Mentor

 Such programs are possible but inadvisable.  If you want the same lineweight for every drawing object, just use the setbylayer command and adjust the layer's lineweight.  Takes 10-15 seconds.  The layer manager is nearly as quick as a program for adjusting layer lineweights.

 

99% of your objects should have a color, lineweight, and linetype of bylayer.  Layer's should govern object properties for maximum advantage in a team environment.

Architect, Registered NC, VA, SC, & GA.
Message 3 of 11

Ajilal.Vijayan
Advisor
Advisor

Hi,

Welcome to this forum.

 

Please try this lisp (minimally tested)

Spoiler
;Select ALL entities on a drawing and change is lineweight from 0.3mm to 0.18mm
(if (ssget "_X" '((370 . 30)))
(command "._change" (ssget "_X" '((370 . 30))) "" "p" "lw" "0.18" "")
);if

;Select ALL entities on a drawing and change is lineweight from 0.6mm to 0.3mm
(if (ssget "_X" '((370 . 60)))
(command "._change" (ssget "_X" '((370 . 60))) "" "p" "lw" "0.30" "")
);if

;Select a layer name (ex.: dims) and change that layer lineweight to 0.13mm
(if (ssget "_X" '((8 . "dims")))
(command "._change" (ssget "_X" '((8 . "dims"))) "" "p" "lw" "0.13" "")
);if

(if (ssget "_X" '((0 . "HATCH")))
;Select ALL hatch entities and change is properties, for example colour, linetype, lineweigth
(command "._change" (ssget "_X" '((0 . "HATCH"))) "" "p" "color" "red" "")
);if

;Select All entities with linetype hidden and change it to dashed
(if (ssget "_X" '((6 . "HIDDEN")))
(command "._change" (ssget "_X" '((6 . "HIDDEN"))) "" "p" "lt" "DASHED" "")
);if

 

Also have you tried AutoCAD QSELECT command ?

See this image for to see how you can use QSELECT to select the objects with lineweight 0.13mm

After the selection you can change the properties of that objects via properties dialog box.

Spoiler
quick_select.JPG

 

Message 4 of 11

Anonymous
Not applicable

Hello,

You are right. We always can use the bylayer option, or even the quick selection.

But just as example, some files we received on the same layer have entities with different lineweights or different colours... so the bylayer option in some cases may get unwanted kind of visual look after printing.

Thank you.

 

0 Likes
Message 5 of 11

Anonymous
Not applicable

 

Hello Mr. Ajilal Vijayan

Thank you by your welcome.

 

I looked to you sample lisp file, it seems to work, but as I saw it only changes all entities to 0.6mm. It does nor change the entities from 0.30 to 0.18

Is something to adjust or refine on the lisp file.

By the way, when can I find the "370 . 30" codes you used on the lisp? It exists any information about this codes and its "meaning"?

 

sorry about my poor english language...

Thank you.

 

 

 

 

0 Likes
Message 6 of 11

Anonymous
Not applicable

 

I was thinking on this subject, and something passes on my mind...

When we assign a plotstyle table for printing, we make a correspondence from a colour then it will be printed with the thickness we choose, for example colour1 red - printed with 0.5mm

Is possible to have on the plotstyle table a correspondence for the lweights? For example the lineweights 0.6 on the drawing file to be printed with 0.3mm... Is something similar to the colours thickness on the plotstyle table but apllied to the lweights...

 

Thank you.

 

0 Likes
Message 7 of 11

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

 

...

By the way, when can I find the "370 . 30" codes you used on the lisp? It exists any information about this codes and its "meaning"?

...

Thank you.

 

 

 

 


Try Autocad (online) help system. Type name of entity and "dxf" like... 

TEXT DXF

http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-62E5383D-8A14-47B4-BFC4-35824CAE8363

or for common group codes...

http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-3610039E-27D1-4E23-B6D3-7E60B22BB5BD

0 Likes
Message 8 of 11

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

 

I was thinking on this subject, and something passes on my mind...

When we assign a plotstyle table for printing, we make a correspondence from a colour then it will be printed with the thickness we choose, for example colour1 red - printed with 0.5mm

Is possible to have on the plotstyle table a correspondence for the lweights? For example the lineweights 0.6 on the drawing file to be printed with 0.3mm... Is something similar to the colours thickness on the plotstyle table but apllied to the lweights...

 

Thank you.

 


 

 

 

No, that is not possible. You can have CTB for color depend tables or STB - style tables. Style of STB you assign to LAYER but manually, not automatically. Change from CTB to STB is not that easy, you need have drawing based on different template.

Message 9 of 11

Anonymous
Not applicable

 

Hello again Mr. Ajilal Vijayan

 

I tried you sample code, and it seem to work a little. The code change ALL entities on the file to 0.3mm, is really ALL entities...

I must say sorry to you because my bad english, when I mean ALL is not all entities inside the file... I mean ALL entities only that have a lweight of 0.6 to change to 0.3 this is a little different...

For example, if the file have total 100 entities and 20 of them have 0.6 on lweight is only that 20 ones I want to change to 0.3... I wanted to mean ALL that have 0.6

Is possible from you to help on this subject?

 

Sorry again for may beginner FAULT...

Thank you.

 

0 Likes
Message 10 of 11

Anonymous
Not applicable

 

Hello Mr. BeeKeeCZ

 

Thank you for your 2 explanation replies. Very usefully. I will see the documentation.

I am new on this forum, and until now it seems very good, and good and quick replies.

You all receive a "like" Smiley Happy for this actual and future help.

 

Thank you.

 

0 Likes
Message 11 of 11

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

I was thinking on this subject, and something passes on my mind...

When we assign a plotstyle table for printing, we make a correspondence from a colour then it will be printed with the thickness we choose, for example colour1 red - printed with 0.5mm

Is possible to have on the plotstyle table a correspondence for the lweights? For example the lineweights 0.6 on the drawing file to be printed with 0.3mm... Is something similar to the colours thickness on the plotstyle table but apllied to the lweights...

Thank you.


I think you must misunderstood something. Lisps work good and what you asked to do. Try it again.
Save it as *.lsp and load with _APPLOAD. Command is MyPropChange
(defun C:MyPropChange ()

;Select ALL entities on a drawing and change is lineweight from 0.3mm to 0.18mm
(if (ssget "_X" '((370 . 30)))
(command "._change" (ssget "_X" '((370 . 30))) "" "p" "lw" "0.18" "")
);if

;Select ALL entities on a drawing and change is lineweight from 0.6mm to 0.3mm
(if (ssget "_X" '((370 . 60)))
(command "._change" (ssget "_X" '((370 . 60))) "" "p" "lw" "0.30" "")
);if

;Select a layer name (ex.: dims) and change that layer lineweight to 0.13mm
(if (ssget "_X" '((8 . "dims")))
(command "._change" (ssget "_X" '((8 . "dims"))) "" "p" "lw" "0.13" "")
);if

(if (ssget "_X" '((0 . "HATCH")))
;Select ALL hatch entities and change is properties, for example colour, linetype, lineweigth
(command "._change" (ssget "_X" '((0 . "HATCH"))) "" "p" "color" "red" "")
);if

;Select All entities with linetype hidden and change it to dashed
(if (ssget "_X" '((6 . "HIDDEN")))
(command "._change" (ssget "_X" '((6 . "HIDDEN"))) "" "p" "lt" "DASHED" "")
);if
)

 

0 Likes