Jump to content

Put xline on a specific layer.


Recommended Posts

Posted (edited)

Hi,

 

(defun c:x ()
(setq cl (getvar "clayer"))
(command "-layer" "s" "help" "")
(command "xline")
(setvar "clayer" cl)
);defun

 

Why does the he layer remain the same while drawing?

How to modify it to draw a horizontal (x) or a vertical (xx)?

 

The basic idea is to invoke x (or xx) have it change layer to help, draw an xline and then go back to previous layer.

Thanks!

 

 

Edited by SLW210
Added Code Tags!
Posted

A few comments 

 

X is the shortcut for Explode I always type a shortcut like this to see if it exists. Use say "XX" & "YY".

I would use '"Layer" "M" as it makes the layer if it does not exist, also sets it current.

Use Comand-s for the xline it will ask for more details or just make your command correct by completing the requests when running XLINE.

 

(command "xline" "H" (getpoint "\nPick point ") "")

(command "xline" "V" (getpoint "\nPick point ") "")

 

When making a lisp always look at the manual version, write the prompts down on a bit of paper.

  • Like 1
Posted (edited)

Helping out SLW210

 

@Discus84 Use <> when posting code

code-post-1.png.d4f30f78f1e2328d85b9144975da9183.png.9e11748480c91a4f3c788a36387890e3.png

 

 

Edited by mhupp
Posted
(defun C:x (/ pt)
  	(setq cl (getvar "clayer"))
	(command "-layer" "s" "help" "")
	(setq pt (getpoint))
    (command "_.Xline" "_ver" "_none" pt "")
	(setvar "clayer" cl)
 	(princ)
)

(defun C:xx (/ pt)
  	(setq cl (getvar "clayer"))
	(command "-layer" "s" "help" "")
	(setq pt (getpoint))
    (command "_.Xline" "_hor" "_none" pt "")
	(setvar "clayer" cl)
	(princ)
)

This works. How to combine it into one function to skip all the double code?

Posted
(defun c:xh (/ bp)
  (prompt "\nXLINE HORIZONTAL")
  (setq bp (getpoint "\nSpecify basepoint: "))
  (entmake (list (cons 0 "XLINE")
		 (cons 100 "AcDbEntity")
		 (cons 100 "AcDbXline")
		 (cons 8 "help");; update your layer here
		 (cons 10 (trans bp 1 0))
		 (cons 11 (getvar 'ucsxdir))
		 )
	   )
  (princ)
  )
(defun c:xv (/ bp)
  (prompt "\nXLINE VERTICAL")
  (setq bp (getpoint "\nSpecify basepoint: "))
  (entmake (list (cons 0 "XLINE")
		 (cons 100 "AcDbEntity")
		 (cons 100 "AcDbXline")
		 (cons 8 "help");; update your layer here
		 (cons 10 (trans bp 1 0))
		 (cons 11 (getvar 'ucsydir))
		 )
	   )
  (princ)
  )

here you go without using the "command" function.

Posted (edited)

You might be interested in the program I posted here.

Edited by Lee Mac
Posted

A couple of comments.

 

Like Lee's solution can do a front end using Multi radio buttons.lsp so pick direction. Example code is in top of the attached.

 

You can make an extra defun that holds the entmake code as the only difference in the code by Lanloylisp is to pass the UCSXDIR or YDIR, (cons 11 ucsdirXY) so set UCSDIRXY in the XH & XV.

 

A good idea defun name, XV & XH & XA. Remember X is shortcut for EXPLODE.

 

Multi radio buttons.lsp

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...