Jump to content

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.lspUnavailable

Posted
  On 1/17/2025 at 12:46 PM, Lee Mac said:

You might be interested in the program I posted here.

 

I've now updated this program and added it to my site here.

  • Like 1
Posted

@Lee Mac

(c:x) will override built-in pgp setting for EXPLODE command... If you are still present, I suggest that instead of "X" you use something like (c:xx)... I believe this makes some sense...

Posted (edited)
  On 1/18/2025 at 6:17 PM, marko_ribar said:

@Lee Mac

(c:x) will override built-in pgp setting for EXPLODE command... If you are still present, I suggest that instead of "X" you use something like (c:xx)... I believe this makes some sense...

 

I use xlines more often than explode, so this works for me :)

But perhaps a two character syntax for all commands would be more consistent - I'll tweak it.

Edited by Lee Mac
Posted
  Quote

I use xlines more often than explode, so this works for me 

Same here. Incidentally , another topic comes up and I wonder what is the procedure for checking frequency of commands used over a period of time. 

This would be helpful in organizing a concise set of most frequent commands(single character) and a convention for the other, less used ones (two character).

Posted
  On 1/20/2025 at 6:18 PM, Discus84 said:

Same here. Incidentally , another topic comes up and I wonder what is the procedure for checking frequency of commands used over a period of time. 

This would be helpful in organizing a concise set of most frequent commands(single character) and a convention for the other, less used ones (two character).


This old program could potentially be adapted to apply to all commands and aggregrate the counts independent of the drawings in which they were used.

Posted (edited)

Another logger. I have used this to log multiple users and write a file for each user. You can (getvar 'username) so have a cond where the name is compared to the output file name. I removed some of the details to make reports shorter.

 

Productivity_Analysis_Tool.lspFetching info...

Edited by BIGAL
  • 2 weeks later...
Posted

Lots of good stuff, thanks!

One more thing related here :

1) I would like to be able to exclude the xline from stretch (stretch affects the objects in drawing , not xline)

2) Is there a way to have an xline that is not affected by stretch but affected by  erase, copy etc

 

Objective would be :

-creating an xline (moving it to help layer)

-returning to drawing layer

-stretching objects to reference lines without moving the reference lines.

-deleting xlines

 

 

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...