Drawing a line....!

Drawing a line....!

robw
Advocate Advocate
1,009 Views
6 Replies
Message 1 of 7

Drawing a line....!

robw
Advocate
Advocate

Hi, this is a silly thing to fall over on, but it's been a long time since I looked at Lisp.

 

All I want to do is create a button on my ribbon that when pressed, draws a polyline on a layer using a LTS of 0.25, then returns the user to the previous layer and resetting the LTS back to 1.0.

Assume the new layer already exists in the drawing (I use STEALv1-8.lsp to import the layer, after the defun command).

 

All I've got is:

 

(defun c:drawline_non-printing ( )
(setvar 'clayer "- non printing")
(command "_pline")
(princ)
)

 

Hahaha

 

Any help / ideas?

Thanks

 

Civil 2018

0 Likes
Accepted solutions (1)
1,010 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution
(defun c:drawline_non-printing (/ l s )
  (setq l (getvar 'clayer)
	s (getvar 'celtscale))
  (or (tblsearch "LAYER" "- non printing") ; does it exist?
      (command "_.layer" "_n" "- non printing" "_plot" "_no" "" ""))  ; Create new if not
  (setvar 'clayer "- non printing")
  (setvar 'celtscale 0.25)
  (command-s "_pline")
  (setvar 'clayer l)
  (setvar 'celtscale s)
  (princ)
  )
Message 3 of 7

robw
Advocate
Advocate

You are a star!

Thanks

 

0 Likes
Message 4 of 7

Moshe-A
Mentor
Mentor

@robw  hi,

 

how about that?

 

(defun c:drawline_non-printing (/ savCLayer layerName savLTScale)
 (setq savCLayer (getvar 'clayer))
 (setq layerName "- non printing")

 (setq savLTScale (getvar 'ltscale))
 (setvar 'ltscale 0.25)
  
 (if (tblsearch "layer" layerName)
  (setvar 'clayer "- non printing")
  (command "._layer" "_m" layerName "_plot" "_no" "" "")
 )
  
 (command-s "._pline")

 (setvar 'ltscale savLTScale)
 (setvar 'clayer savCLayer)
  
 (princ)
)

 

 

0 Likes
Message 5 of 7

Kent1Cooper
Consultant
Consultant

Another way, without having to save and restore anything:

 

(defun c:drawline_non-printing ()
  (command-s "_pline")
(command "_.chprop" "_last" "" "_layer" "- non printing" "_ltscale" 0.25 "") (princ) )
Kent Cooper, AIA
0 Likes
Message 6 of 7

rrowe24N24
Contributor
Contributor

got a question

when I'm trying to manually stretch or trim a wire/line it is not staying straight.

how can I correct this.

is there a setting in object snap

0 Likes
Message 7 of 7

ВeekeeCZ
Consultant
Consultant

@rrowe24N24 wrote:

got a question

when I'm trying to manually stretch or trim a wire/line it is not staying straight.

how can I correct this.

is there a setting in object snap


 

How is this related to the topic? 

Start a new topic, please.

0 Likes