Jump to content

Recommended Posts

Posted (edited)

I'm having an issue with a selection set.

 

This is a work in progress but what it does is creates 3d grating out the grate hatch pattern.

 

The problem I'm having is after the lines are turned into polylines, I'm losing the selection set "SS2".

(defun c:ttt (/ OS PTZ SS SS2)
  (setq OS (getvar 'osmode))
  (setvar 'osmode 7)
  (command "id" pause)
  (setq PTZ (rtos (setq PTZ# (caddr (getvar 'lastpoint))) 4 4))
  (command "-hatch" "_P" "Grate" "32" "" "S" pause "" "")
  (setq SS (entlast))
  (command "_.CHANGE" SS "" "_P" "_E" PTZ "")
  (command "explode" SS)
  (setq SS2 (ssget "_P"))
  (command "_pedit" "m" SS2 "" "y" "w" "3/16" "")
  (command "_.CHANGE" SS2 "" "_P" "_T" "1" "") ;;;SS2 stops working
  )

On a side note, how come this works:

(command "id" pause)
(setq PTZ (rtos (setq PTZ# (caddr (getvar 'lastpoint))) 4 4))

 

But this doesn't work:

( getpoint "\nTEST POINT : ")
(setq PTZ (rtos (setq PTZ# (caddr (getvar 'lastpoint))) 4 4))

 

Edited by jonathann3891
Posted
3 hours ago, jonathann3891 said:

On a side note, how come this works:


(command "id" pause)
(setq PTZ (rtos (setq PTZ# (caddr (getvar 'lastpoint))) 4 4))

But this doesn't work:


( getpoint "\nTEST POINT : ")
(setq PTZ (rtos (setq PTZ# (caddr (getvar 'lastpoint))) 4 4))

 

 

The LASTPOINT system variable stores the last point supplied to a command, not the last point obtained using an AutoLISP expression.

 

However, neither of the two methods you have posted are necessary, as you can use getpoint directly, e.g.:

(if (setq pt (getpoint "\nTest point: "))
    (setq ptz# (caddr pt)
          ptz  (rtos ptz# 4 4)
    )
)

 

Posted
3 hours ago, jonathann3891 said:

The problem I'm having is after the lines are turned into polylines, I'm losing the selection set "SS2".


(defun c:ttt (/ OS PTZ SS SS2)
  (setq OS (getvar 'osmode))
  (setvar 'osmode 7)
  (command "id" pause)
  (setq PTZ (rtos (setq PTZ# (caddr (getvar 'lastpoint))) 4 4))
  (command "-hatch" "_P" "Grate" "32" "" "S" pause "" "")
  (setq SS (entlast))
  (command "_.CHANGE" SS "" "_P" "_E" PTZ "")
  (command "explode" SS)
  (setq SS2 (ssget "_P"))
  (command "_pedit" "m" SS2 "" "y" "w" "3/16" "")
  (command "_.CHANGE" SS2 "" "_P" "_T" "1" "") ;;;SS2 stops working
  )

 

 

You will need to obtain the last entity in the database (using entlast) prior to issuing the PEDIT command, and then step through and collect the entities added by the PEDIT command (using entnext).

Posted

Alternative:

Put the hatch on a temporary dedicated layer. You can then create create SS, SS2 and SS3 by filtering for that layer.

Posted
1 hour ago, Roy_043 said:

Alternative:

Put the hatch on a temporary dedicated layer. You can then create create SS, SS2 and SS3 by filtering for that layer.

 

Great idea Roy, I've never previously considered that route. :thumbsup:

Posted (edited)

My $0.05 would it not be easier to just make the grate as line work  you can group objects so it appears as 1 object, if you want as a full solid again not a problem. You can have different types or spacings. Here in AUS we use a weave grate a lot as its bicycle safe. A quick 3d is to use lines and thickness its about how accurate you want.

 

image.png.7ab3371c97ffbbd85e81341c53542a04.pngimage.png.8f6e5d818c6e3a180e3571d1a7cc5ec9.png

 

 

Edited by BIGAL
Posted
15 hours ago, Lee Mac said:

 

Great idea Roy, I've never previously considered that route. :thumbsup:

Main reason for this approach: entlast is not very reliable.

Posted
20 hours ago, Lee Mac said:

 

The LASTPOINT system variable stores the last point supplied to a command, not the last point obtained using an AutoLISP expression.

 

However, neither of the two methods you have posted are necessary, as you can use getpoint directly, e.g.:


(if (setq pt (getpoint "\nTest point: "))
    (setq ptz# (caddr pt)
          ptz  (rtos ptz# 4 4)
    )
)

 

That's way better than the way I was doing it, Thanks Lee!

 

Posted

I found something from Kent Cooper that's working.

;;  LastNo.LSP [function name: LN]
;;  To select the Last user-specified Number of Entities
;;  Use by typing (LN qu) where 'qu' is integer quantity of entities desired
;;  Kent Cooper; last edited July 2009
;;
(defun LN (qu / sset ssn)
  (setq sset (ssadd))
  (repeat qu
    (if (entlast)
      (progn
        (ssadd (entlast) sset)
        (entdel (entlast))
      ); end progn
    ); end if
  ); end repeat
  (if sset
    (progn
      (setq ssn (sslength sset))
      (while (>= (setq ssn (1- ssn)) 0)
        (entdel (ssname sset ssn))
        (redraw (entlast) 3)
      ); end while
    ); end progn
  ); end if
  sset
); end defun

 

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