Author Topic: Understanding using Polylines within Lisps  (Read 3045 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Understanding using Polylines within Lisps
« 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)

Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7524
Re: Understanding using Polylines within Lisps
« Reply #1 on: December 08, 2017, 09:16:28 AM »
Maybe you can use THIS.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Understanding using Polylines within Lisps
« Reply #2 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.
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7524
Re: Understanding using Polylines within Lisps
« Reply #3 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! :) Glad you're using it.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Understanding using Polylines within Lisps
« Reply #4 on: December 08, 2017, 09:54:58 AM »
I forgot about that parking stall code! :) Glad you're using it.

I like this one! :thumbsup:
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

ronjonp

  • Needs a day job
  • Posts: 7524
Re: Understanding using Polylines within Lisps
« Reply #5 on: December 08, 2017, 10:01:46 AM »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Understanding using Polylines within Lisps
« Reply #6 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.

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Understanding using Polylines within Lisps
« Reply #7 on: December 08, 2017, 10:13:00 AM »
Im curious.... How does the OSMODE mode have an effect?
Civil3D 2020

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Understanding using Polylines within Lisps
« Reply #8 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.

Lee Mac

  • Seagull
  • Posts: 12904
  • London, England

BIGAL

  • Swamp Rat
  • Posts: 1392
  • 40 + years of using Autocad
Re: Understanding using Polylines within Lisps
« Reply #10 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)
A man who never made a mistake never made anything

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Understanding using Polylines within Lisps
« Reply #11 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.
Civil3D 2020

MeasureUp

  • Bull Frog
  • Posts: 461
Re: Understanding using Polylines within Lisps
« Reply #12 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.


ahsattarian

  • Newt
  • Posts: 112
Re: Understanding using Polylines within Lisps
« Reply #13 on: July 12, 2021, 11:32:20 PM »



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