TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MeasureUp on July 20, 2022, 08:12:01 PM

Title: Questions about Command "Change"
Post by: MeasureUp on July 20, 2022, 08:12:01 PM
Here is an example.
I want to restore the linetype scale of everything to "1" both model space and layout(s) on an existing drawing.
I notice the command "Change" will terminate when (setvar "tilemode" 1) and it finds entities on layout.

= = = = =
Edit:
I use (ssget "_X") to select everything on the entire drawing.
= = = = =

Your helps are much appreciated.
Title: Re: Questions about Command "Change"
Post by: ribarm on July 20, 2022, 10:57:24 PM
Of course, you can do it by LISP...
Iterate through (ssget "_X"), check for availability of DXF group code for carrying line type scale... I think something like (48 . 1.0) ; and just change it...
Title: Re: Questions about Command "Change"
Post by: MeasureUp on July 20, 2022, 11:41:07 PM
Of course, you can do it by LISP...
Iterate through (ssget "_X"), check for availability of DXF group code for carrying line type scale... I think something like (48 . 1.0) ; and just change it...

What to do if there are non-line type entities on the drawing (e.g. circles, blocks...)?
Can (ssget "_X") still be applicable for getting linetype scale?
Thanks.
Title: Re: Questions about Command "Change"
Post by: ribarm on July 21, 2022, 12:57:12 AM
Of course, you can do it by LISP...
Iterate through (ssget "_X"), check for availability of DXF group code for carrying line type scale... I think something like (48 . 1.0) ; and just change it...

What to do if there are non-line type entities on the drawing (e.g. circles, blocks...)?
Can (ssget "_X") still be applicable for getting linetype scale?
Thanks.

There is no need to worry, just check preliminary for DXF 48 :

Code: [Select]
(defun c:foo ( / ss i ex )
  (if (setq ss (ssget "_X"))
    (repeat (setq i (sslength ss))
      (setq ex (entget (ssname ss (setq i (1- i)))))
      (if (assoc 48 ex)
        (entupd (cdr (assoc -1 (entmod (subst (cons 48 1.0) (assoc 48 ex) ex)))))
      )
    )
  )
  (princ)
)
Title: Re: Questions about Command "Change"
Post by: MeasureUp on July 21, 2022, 02:42:04 AM
Great it works.

The code will return something shown below if I pick only one line.

Code: [Select]
(setq ex (entget (ssname ss (setq i (1- i))))) returns:

((-1 . <Entity name: 26b7bd428d0>) (0 . "LWPOLYLINE") (330 . <Entity name: 26b05a4b1f0>) (5 . "394D") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "Floor") (100 . "AcDbPolyline") (90 . 3) (70 . 0) (43 . 0.0) (38 . 0.0) (39 . 0.0) (10 54.7889 930.635) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 895.88 930.635) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 895.88 1590.1) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0))

What is a group code for linetype of line?
I am confused when looking in HELP. Is "6" the answer?
I ask as I also want to reset the linetype property to "Bylayer".

Thanks.
Title: Re: Questions about Command "Change"
Post by: Lee Mac on July 21, 2022, 12:28:28 PM
Aside, you may find this simple utility (http://lee-mac.com/entitylist.html) useful when inspecting the DXF data associated with a given entity (be it graphical or non-graphical).

Where entity linetype is concerned, you are correct - this is held by DXF group 6, however, so as to preserve space, such DXF group will not be present in the DXF data if the property is set to BYLAYER (however, it is worth noting that such entities will still be selected by an ssget expression using a filter list containing (6 . "BYLAYER") even though this DXF group is not explicitly stated in the DXF data).

To set the linetype of all entities to BYLAYER, you can use something along the lines of the following:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:ltbylayer ( / i s x )
  2.     (if (setq s (ssget "_X" '((-4 . "<NOT") (6 . "BYLAYER") (-4 . "NOT>"))))
  3.         (repeat (setq i (sslength s))
  4.             (setq i (1- i)
  5.                   x (entget (ssname s i))
  6.             )
  7.             (entmod (subst '(6 . "BYLAYER") (assoc 6 x) x))
  8.         )
  9.     )
  10.     (princ)
  11. )
Title: Re: Questions about Command "Change"
Post by: MeasureUp on July 21, 2022, 09:06:06 PM
Thanks Lee.
Your website is very informative & helpful...

I'd like to explore more from entity properties.
Q1.
Apart from "color" and "linetype", what are the group codes for lineweight, transparency, material?
I am not sure if "370" is the group code of "lineweight".

Q2.
And it is a bit interesting (62 . "Bylayer") doesn't work for setting color to "bylayer" instead of (62 . 256).
Is it correct?
Then how to set it to "byblock"?

Q3.
Furthermore, how to set "bylayer" or "byblock" to "lineweight", "transparency" and "material" as they are not numeric values?
Title: Re: Questions about Command "Change"
Post by: ronjonp on July 22, 2022, 02:36:49 PM
Thanks Lee.
Your website is very informative & helpful...

I'd like to explore more from entity properties.
Q1.
Apart from "color" and "linetype", what are the group codes for lineweight, transparency, material?
I am not sure if "370" is the group code of "lineweight".

Q2.
And it is a bit interesting (62 . "Bylayer") doesn't work for setting color to "bylayer" instead of (62 . 256).
Is it correct?
Then how to set it to "byblock"?

Q3.
Furthermore, how to set "bylayer" or "byblock" to "lineweight", "transparency" and "material" as they are not numeric values?
Have a read here: http://docs.autodesk.com/ACAD_E/2012/ENU/filesDXF/WS1a9193826455f5ff18cb41610ec0a2e719-7a62.htm
Title: Re: Questions about Command "Change"
Post by: MeasureUp on July 24, 2022, 08:15:57 PM
Sorry, as I mentioned I have read the HELP but I haven't figured it out.
Title: Re: Questions about Command "Change"
Post by: Lee Mac on July 25, 2022, 05:01:22 PM
Q1.
Apart from "color" and "linetype", what are the group codes for lineweight, transparency, material?
I am not sure if "370" is the group code of "lineweight".

The group codes common to all entities may be found here (https://help.autodesk.com/view/ACD/2018/ENU/?guid=GUID-3610039E-27D1-4E23-B6D3-7E60B22BB5BD); in short, for the basic object properties, we have:Per the linked reference, material is stored by DXF group 347 (a pointer to the material entity), and entity transparency is stored by DXF group 440.

Q2.
And it is a bit interesting (62 . "Bylayer") doesn't work for setting color to "bylayer" instead of (62 . 256).
Is it correct?
Then how to set it to "byblock"?

DXF group codes have specific data types (https://help.autodesk.com/view/ACD/2018/ENU/?guid=GUID-2553CF98-44F6-4828-82DD-FE3BC7448113) based on the range within which the group code falls; per the reference, DXF groups 60-79 are always 16-bit integer values, hence DXF group 62 must hold a 16-bit integer value.

Per the first linked reference, use 256 for ByLayer and 0 for ByBlock.

Q3.
Furthermore, how to set "bylayer" or "byblock" to "lineweight", "transparency" and "material" as they are not numeric values?

These are all explained in the references linked above.
Title: Re: Questions about Command "Change"
Post by: MeasureUp on July 25, 2022, 09:53:38 PM
Thanks for your time, Lee.

As HELP mentions, group value of "370-379" are 16-bit integer value.
I then tried (370 . 256) for setting lineweight to "bylayer" but it doesn't work either.
And lineweight will return "0" (not "byblock") if group code "370" is set to "0".
What did I miss?
Title: Re: Questions about Command "Change"
Post by: tombu on July 26, 2022, 07:54:33 AM
Thanks for your time, Lee.

As HELP mentions, group value of "370-379" are 16-bit integer value.
I then tried (370 . 256) for setting lineweight to "bylayer" but it doesn't work either.
And lineweight will return "0" (not "byblock") if group code "370" is set to "0".
What did I miss?
As Lee explained if group code "370" is set to "0" then the entity's lineweight is "ByBlock".
You need to post code before anyone can fix it for you.
Maybe this reference will help.
Common Group Codes for Entities (DXF): https://help.autodesk.com/view/ACD/2023/ENU/?guid=GUID-3610039E-27D1-4E23-B6D3-7E60B22BB5BD (https://help.autodesk.com/view/ACD/2023/ENU/?guid=GUID-3610039E-27D1-4E23-B6D3-7E60B22BB5BD)
Title: Re: Questions about Command "Change"
Post by: Lee Mac on July 26, 2022, 05:54:41 PM
As HELP mentions, group value of "370-379" are 16-bit integer value.
I then tried (370 . 256) for setting lineweight to "bylayer" but it doesn't work either.
And lineweight will return "0" (not "byblock") if group code "370" is set to "0".
What did I miss?

You'll need to read the documentation and occasionally experiment with existing entities when working with each specific DXF group code - what is true for one DXF group (e.g. 62) may not necessarily be true for others of the same data type (e.g. 370).

In this case, lineweight is governed by the following enumerations:
Code: [Select]
enum AcLineWeight;
{
  acLnWt000 = 0,
  acLnWt005 = 5,
  acLnWt009 = 9,
  acLnWt013 = 13,
  acLnWt015 = 15,
  acLnWt018 = 18,
  acLnWt020 = 20,
  acLnWt025 = 25,
  acLnWt030 = 30,
  acLnWt035 = 35,
  acLnWt040 = 40,
  acLnWt050 = 50,
  acLnWt053 = 53,
  acLnWt060 = 60,
  acLnWt070 = 70,
  acLnWt080 = 80,
  acLnWt090 = 90,
  acLnWt100 = 100,
  acLnWt106 = 106,
  acLnWt120 = 120,
  acLnWt140 = 140,
  acLnWt158 = 158,
  acLnWt200 = 200,
  acLnWt211 = 211,
  acLnWtByLayer = -1,
  acLnWtByBlock = -2,
  acLnWtByLwDefault = -3
};

Title: Re: Questions about Command "Change"
Post by: BIGAL on July 26, 2022, 10:42:06 PM
This may help I know I had problems making it work.

(vlax-put-property obj "Linetype" "Bylayer")

(vlax-put-property obj "Color" acbylayer)
Title: Re: Questions about Command "Change"
Post by: Lee Mac on July 27, 2022, 08:12:56 AM
This may help I know I had problems making it work.

(vlax-put-property obj "Linetype" "Bylayer")
;(vlax-put-property obj "Lineweight" acbylayer)
(vlax-put-property obj "Color" acbylayer)

You're using the wrong enumeration for the Lineweight property - refer to my above post.
Title: Re: Questions about Command "Change"
Post by: BIGAL on July 27, 2022, 09:14:40 PM
Thanks Lee changed it in post I just cut out of some code new there was a reason for it to be commented out code was like 5 years old. Had problems at the time getting it to work.