Author Topic: LineWeight not as string  (Read 3283 times)

0 Members and 1 Guest are viewing this topic.

HofCAD

  • Guest
LineWeight not as string
« on: March 31, 2015, 05:57:47 AM »
Dear Readers,

Why is it impossible in a regular AutoCAD to specify the LineWeight as a string?
Because it is possible in educational version of AutoCAD!
(vla-put-Lineweight NewLayer 18) versus (vla-put-Lineweight NewLayer "0.18")

Regards.

Code: [Select]
(defun c:Test1 ();Works in regular AutoCAD and educational AutoCAD
(vl-load-com)
(setq doc (vla-get-ActiveDocument
    (vlax-get-Acad-Object)
  )
)
(setq LayerCollection (vla-Get-Layers doc))
(setq NewLayer (vla-add LayerCollection "Layer1"))
(vla-put-color NewLayer "4")
(if (not (tblobjname "ltype" "CENTER"))
  (vla-load (vla-Get-Linetypes doc) "CENTER" "acadiso.lin")
)
(vla-put-linetype NewLayer "CENTER")
(vla-put-Lineweight NewLayer 18) ; ADD A lineweight.
)
Code: [Select]
(defun c:Test2 ();Works only in educational AutoCAD
(vl-load-com)
(setq doc (vla-get-ActiveDocument
    (vlax-get-Acad-Object)
  )
)
(setq LayerCollection (vla-Get-Layers doc))
(setq NewLayer (vla-add LayerCollection "Layer2"))
(vla-put-color NewLayer "4")
(if (not (tblobjname "ltype" "CENTER"))
  (vla-load (vla-Get-Linetypes doc) "CENTER" "acadiso.lin")
)
(vla-put-linetype NewLayer "CENTER")
(vla-put-Lineweight NewLayer "0.18") ; ADD A lineweight.
)

ChrisCarlson

  • Guest
Re: LineWeight not as string
« Reply #1 on: March 31, 2015, 08:07:17 AM »
vla-put-lineweight must be an integer along with matching the following

-3 (ByLwDeafault)
-2 (ByBlock)
-1 (ByLayer)
0, 5, 9, 13, 15, 18, 20, 25, 30, 35, 40, 50, 53, 60, 70, 80, 90, 100, 106, 120, 140, 158, 200, 211

18 =/= ".18"

http://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-ActiveX/files/GUID-DE1AC635-BCEA-428F-A47D-80E35EFE55D3-htm.html


Educational version may work however it could be setting the value to LWDEFAULT instead of .18
« Last Edit: March 31, 2015, 08:30:21 AM by ChrisCarlson »

HofCAD

  • Guest
Re: LineWeight not as string
« Reply #2 on: March 31, 2015, 09:56:53 AM »
vla-put-lineweight must be an integer along with matching the following

-3 (ByLwDeafault)
-2 (ByBlock)
-1 (ByLayer)
0, 5, 9, 13, 15, 18, 20, 25, 30, 35, 40, 50, 53, 60, 70, 80, 90, 100, 106, 120, 140, 158, 200, 211

18 =/= ".18"

http://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-ActiveX/files/GUID-DE1AC635-BCEA-428F-A47D-80E35EFE55D3-htm.html


Educational version may work however it could be setting the value to LWDEFAULT instead of .18
Dear Chris,

Thanks, but ".18" does not work in regular AutoCAD, because I get 0.00!
(see Test3 in Attachment)

Regards

ronjonp

  • Needs a day job
  • Posts: 7526
Re: LineWeight not as string
« Reply #3 on: March 31, 2015, 10:25:23 AM »
In AutoCAD 2016 both of these work:
Code - Auto/Visual Lisp: [Select]
  1.   (vla-put-lineweight newlayer 18)
  2.   (vla-put-lineweight newlayer "18")

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ChrisCarlson

  • Guest
Re: LineWeight not as string
« Reply #4 on: March 31, 2015, 12:14:00 PM »
In AutoCAD 2016 both of these work:
Code - Auto/Visual Lisp: [Select]
  1.   (vla-put-lineweight newlayer 18)
  2.   (vla-put-lineweight newlayer "18")

Do you get the same result?

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: LineWeight not as string
« Reply #5 on: March 31, 2015, 12:14:59 PM »
In AutoCAD 2016 both of these work:
Code - Auto/Visual Lisp: [Select]
  1.   (vla-put-lineweight newlayer 18)
  2.   (vla-put-lineweight newlayer "18")

If I recall, this 'leniency' also applies to the height argument for the addtext method.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: LineWeight not as string
« Reply #6 on: March 31, 2015, 12:35:48 PM »
In AutoCAD 2016 both of these work:
Code - Auto/Visual Lisp: [Select]
  1.   (vla-put-lineweight newlayer 18)
  2.   (vla-put-lineweight newlayer "18")

Do you get the same result?
Yup.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

mailmaverick

  • Bull Frog
  • Posts: 494
Re: LineWeight not as string
« Reply #7 on: April 03, 2015, 03:50:37 AM »
In AutoCAD 2016 both of these work:
Code - Auto/Visual Lisp: [Select]
  1.   (vla-put-lineweight newlayer 18)
  2.   (vla-put-lineweight newlayer "18")

If I recall, this 'leniency' also applies to the height argument for the addtext method.

Why AUTODESK has given this leniency here only ?
Why not this leniency at all other places ?


Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: LineWeight not as string
« Reply #8 on: April 03, 2015, 07:31:14 AM »
In AutoCAD 2016 both of these work:
Code - Auto/Visual Lisp: [Select]
  1.   (vla-put-lineweight newlayer 18)
  2.   (vla-put-lineweight newlayer "18")

If I recall, this 'leniency' also applies to the height argument for the addtext method.

Why AUTODESK has given this leniency here only ?
Why not this leniency at all other places ?

Personally, I would prefer that the leniency were not present at all, and that the functions performed exactly as stated in the documentation - I don't like surprises  :-P

ChrisCarlson

  • Guest
Re: LineWeight not as string
« Reply #9 on: April 03, 2015, 11:34:11 AM »
Seems odd that it allows an integer or string. What happens if you pass a text string? You'd have to include addition error trapping to only allow numerical strings to pass.


Obviously (vla-put-lineweight newlayer "Text") isn't possible.