TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MSTG007 on December 08, 2017, 07:53:46 AM

Title: Understanding using Polylines within Lisps
Post by: MSTG007 on December 08, 2017, 07:53:46 AM
I am playing around with drawing a simple grid for details. However, I get mixed results on different PC's. Some the grid comes in correctly. Others it looks like the below image or similar. I have straight forward commands and did not know if I need to add more "feneese" to it.

thanks again

Code: [Select]
(defun c:GRID()
(command "-layer" "s" "TBTXT" "")
(command "_.pline" "9.1875,23.375" "9.1875,11.5335" "")
(command "_.pline" "16.875,23.375" "16.875,11.5335" "")
(command "_.pline" "24.5625,23.375" "24.5625,11.5335" "")
(command "_.pline" "1.5,11.5335" "32.25,11.5335" "")
(command "_.pline" "12.25,11.5335" "12.25,0.625" "")
(command "_.pline" "21.5048,11.5335" "21.5048,0.625" "")
(command "_.pline" "1.5,17.3256" "32.2400,17.3256" "")
(princ)
); defun
(C:GRID)

Title: Re: Understanding using Polylines within Lisps
Post by: ronjonp on December 08, 2017, 09:16:28 AM
Maybe you can use THIS (https://www.theswamp.org/index.php?topic=25575.msg312811#msg312811).
Title: Re: Understanding using Polylines within Lisps
Post by: MSTG007 on December 08, 2017, 09:32:20 AM
Thanks Ron... I was looking through the code... I remembered the parking routine you helped me with. Im gonna look at that again. I think I can figure that out.
Title: Re: Understanding using Polylines within Lisps
Post by: ronjonp on December 08, 2017, 09:42:22 AM
Thanks Ron... I was looking through the code... I remembered the parking routine you helped me with. Im gonna look at that again. I think I can figure that out.


I forgot about that parking stall code (https://www.theswamp.org/index.php?topic=51356.msg564808#msg564808)! :) Glad you're using it.
Title: Re: Understanding using Polylines within Lisps
Post by: Grrr1337 on December 08, 2017, 09:54:58 AM
I forgot about that parking stall code (https://www.theswamp.org/index.php?topic=51356.msg564808#msg564808)! :) Glad you're using it.

I like this one! :thumbsup:
Title: Re: Understanding using Polylines within Lisps
Post by: ronjonp on December 08, 2017, 10:01:46 AM
I forgot about that parking stall code (https://www.theswamp.org/index.php?topic=51356.msg564808#msg564808)! :) Glad you're using it.

I like this one! :thumbsup:
Thanks!  :)
Title: Re: Understanding using Polylines within Lisps
Post by: roy_043 on December 08, 2017, 10:10:40 AM
The main problem with the OP's code is the fact that the OSMODE setting will have an impact on the outcome.
Title: Re: Understanding using Polylines within Lisps
Post by: MSTG007 on December 08, 2017, 10:13:00 AM
Im curious.... How does the OSMODE mode have an effect?
Title: Re: Understanding using Polylines within Lisps
Post by: roy_043 on December 08, 2017, 10:32:59 AM
When using commands inside your Lisp code the OSMODE setting is respected. So if in your code you draw a polyline from point A and an object snap is available at that point, the command will use that snap point instead of the provided coordinates. Of course the current zoom factor and APERTURE setting play a role as well explaining your 'mixed results'.

To fix the issue you can temporarily set the OSMODE to zero in your code.
Title: Re: Understanding using Polylines within Lisps
Post by: Lee Mac on December 08, 2017, 12:48:09 PM
Refer: https://www.theswamp.org/index.php?topic=53652.0
Title: Re: Understanding using Polylines within Lisps
Post by: BIGAL on December 09, 2017, 12:50:08 AM
Simple answer

Code: [Select]
(defun c:GRID()
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(command "-layer" "s" "TBTXT" "")
(command "_.pline" "9.1875,23.375" "9.1875,11.5335" "")
(command "_.pline" "16.875,23.375" "16.875,11.5335" "")
(command "_.pline" "24.5625,23.375" "24.5625,11.5335" "")
(command "_.pline" "1.5,11.5335" "32.25,11.5335" "")
(command "_.pline" "12.25,11.5335" "12.25,0.625" "")
(command "_.pline" "21.5048,11.5335" "21.5048,0.625" "")
(command "_.pline" "1.5,17.3256" "32.2400,17.3256" "")
(setvar 'osmode oldsnap)
(princ)

); defun
(C:GRID)
Title: Re: Understanding using Polylines within Lisps
Post by: MSTG007 on December 11, 2017, 08:32:09 AM
You guys are on it! Thank you.

Tested it on several PC's. No issues when tested and worked.
Title: Re: Understanding using Polylines within Lisps
Post by: MeasureUp on December 14, 2017, 11:08:21 PM
Yes, "osmode" setting is the trick.

BTW from HELP, it gives info of "osmode"
Type: Integer
Saved in: Registry
IOW, "osmode" setting is not stored in drawing file.
This explains that PCs may show different results when the same LSP loaded.

Title: Re: Understanding using Polylines within Lisps
Post by: ahsattarian on July 12, 2021, 11:32:20 PM



Also u can use  :   "_non"   after command to deactivate osnap temporarily.