Problem with vlisp for layer names in Chinese

Problem with vlisp for layer names in Chinese

Rockit_for_Revit
Advocate Advocate
964 Views
11 Replies
Message 1 of 12

Problem with vlisp for layer names in Chinese

Rockit_for_Revit
Advocate
Advocate

Hello, I tried to run a command on a dwg that has layer names in Chinese e.g: JOINERY-家具定制

The following lisp does not return the correct layer rather JOINERY-???????

(vlax-get-property obj 'Layer) 

the following does not work either:

(vlax-put-property obj 'Layer "JOINERY-家具定制")

 

I had to do the old way eg:

(EntMod Entg 8 "JOINERY-家具定制")

 

I think its a bug in vlisp.

Regards

David

 

0 Likes
965 Views
11 Replies
Replies (11)
Message 2 of 12

paullimapa
Mentor
Mentor

the following sequence works renaming layer from "1" to "JOINERY-家具定制":

(setq obj (vlax-ename->vla-object (tblobjname"layer""1")))
(vla-put-name obj "JOINERY-家具定制")

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 12

paullimapa
Mentor
Mentor

the following works to add layer "JOINERY-家具定制":

(vla-Add (vla-Get-Layers (vla-Get-ActiveDocument (vlax-Get-Acad-Object))) "JOINERY-家具定制"))

  


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 12

paullimapa
Mentor
Mentor

those also only show up as ???? in Autocad 2020. But starting 2021 that's been corrected.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 12

Rockit_for_Revit
Advocate
Advocate

Thank you, I'm using AutoCAD 2025.

The issues are with vlax-get-property and vlax-put-property

0 Likes
Message 6 of 12

Sea-Haven
Mentor
Mentor

Worked Bricscad V24.

 

(vla-put-name obj "JOINERY-家具定制")
0 Likes
Message 7 of 12

paullimapa
Mentor
Mentor

Don't use:

 

(vlax-get-property obj 'Layer) 

 

But use this:

 

vlax-get-property obj 'Name)

 

Likewise, don't use:

 

(vlax-put-property obj 'Layer "JOINERY-家具定制")

 

But use this:

 

(vlax-put-property obj 'Name "JOINERY-家具定制")

 

So the following code sequence will create a list of layers in 2025 and the Chinese characters do show up in the returned list:

 

(setq la_doc (vla-get-ActiveDocument (vlax-get-acad-object)) ; get dwg obj
      la_lyr (vlax-get-property la_doc 'layers) ;; Get the collection of layers in the document
      lst nil
)
(defun layer-lst (theLayer)(setq lst(append lst (list(vlax-get-property theLayer 'Name)))))
(vlax-map-collection la_lyr 'layer-lst) ; create layer name list
(vl-sort lst '<) ; sort layer name list

 

Likewise you can rename a layer named "1" to a name with the Chinese characters: 

 

(setq la_doc (vla-get-ActiveDocument (vlax-get-acad-object)) ; get dwg obj
      la_lyr (vlax-get-property la_doc 'layers) ;; Get the collection of layers in the document
)
(defun layer-ren (theLayer)(if (eq "1" (vlax-get-property theLayer 'Name))(vlax-put-property theLayer 'Name "JOINERY-家具定制")))
(vlax-map-collection la_lyr 'layer-ren)

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 12

paullimapa
Mentor
Mentor

also make sure you've installed the 2025.1.1 update


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 9 of 12

Rockit_for_Revit
Advocate
Advocate

I'm mainly after getting the layer of an existing element and changing its layer, rather than dealing with the layers themselves.

When I dump the element I get ?? under Layer:

; Property values:
; Application (RO) = #<VLA-OBJECT IAcadApplication 00007ff7b5cfa068>
; Area (RO) = 2.14614e+07
; Closed = -1
; ConstantWidth = 0.0
; Coordinate = ...Indexed contents not shown...
; Coordinates = (381813.0 -120502.0 385863.0 -120502.0 385863.0 -125801.0 ... )
; Document (RO) = #<VLA-OBJECT IAcadDocument 000002b583c38068>
; Elevation = 0.0
; EntityTransparency = "ByLayer"
; Handle (RO) = "C53DF54"
; HasExtensionDictionary (RO) = 0
; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 000002f6a6cd6c58>
; Layer = "EQUIPMENT-??"
; Length (RO) = 18698.5

0 Likes
Message 10 of 12

paullimapa
Mentor
Mentor

As I mentioned I only see those ??? with the older 2020 version.

And I don't see that problem in my 2025.1

 

paullimapa_0-1732490396510.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 11 of 12

Rockit_for_Revit
Advocate
Advocate

I have 2025.1.1

Rockit_for_Revit_0-1732491274368.png

Attached is a sample of the dwg

 

0 Likes
Message 12 of 12

paullimapa
Mentor
Mentor

I still have no problems listing the layers with the chinese characters using vlisp.

Perhaps it's time for you to submit a trouble ticket through your management portal.

Also include your Windows OS version. I'm still on Windows 10.

paullimapa_0-1732491900454.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes