TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: HofCAD on March 31, 2015, 05:57:47 AM

Title: LineWeight not as string
Post by: HofCAD 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.
)
Title: Re: LineWeight not as string
Post by: ChrisCarlson 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
Title: Re: LineWeight not as string
Post by: HofCAD 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
Title: Re: LineWeight not as string
Post by: ronjonp 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")
Title: Re: LineWeight not as string
Post by: ChrisCarlson 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?
Title: Re: LineWeight not as string
Post by: Lee Mac 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.
Title: Re: LineWeight not as string
Post by: ronjonp 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.
Title: Re: LineWeight not as string
Post by: mailmaverick 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 ?

Title: Re: LineWeight not as string
Post by: Lee Mac 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
Title: Re: LineWeight not as string
Post by: ChrisCarlson 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.