Jump to content

SSGET to grab both Polylines AND lines (Arcs too?)


RLispLearner

Recommended Posts

Hi All,

I've combined code from other users to make a routine that will add a sphere to the end points of any selected group of polylines. Might by ugly, but It works.... 😀

What I'm trying to do is to add "Lines" to the list as well as Polylines so a sphere is added to both entities (and arcs if possible as well...)

 

Im not getting the syntax for the SSGET correct to select both polylines and lines.  I commented out all my failing attempts. Anyone know the proper syntax?

Thanks in Advance!

 

My Code:

(defun c:multisphereinput (/ s sp tmp spherenum)

 (setq spherenum (getreal "\nEnter sphere size: ")); user puts in a real number

  (if spherenum
    (prompt (strcat "\nUser entered: " (rtos spherenum))); display the number
    (prompt "\nUser did not provide a number."); display an error
  )

(princ "\nSelect paths to add Spheres: ");Select multiple lines.

         (cond    ((setq s (ssget '((0 . "*polyline")))); just selects the polylines only. it works.

;;;;trying to select both ploylines and lines. Cant select the lines;;;;
;;;; My attempts below;;;;

     ;;;; (cond    ((setq s (ssget '((0 . "*polyline")(0 . "*LINE")))); does not get lines. only Polylines
     ;;;; (cond    ((setq s (ssget '((0 . "*polyline")'(0 . "*LINE")))); "Bad ssget"
     ;;;; (cond    ((setq s (ssget  (list '(0 . "*polyline")'(0 . "*LINE")))); does not get lines. only Polylines
     ;;;; (cond    ((setq s (ssget  (list '((0 . "*polyline")'(0 . "*LINE"))))); "Bad ssget"
     ;;;; (cond    ((setq s (ssget '(("LINE,*POLYLINE"))));  "Bad ssget"
     ;;;; (cond    ((setq s (ssget "_X" '(list ("LINE,*POLYLINE")))); "Bad ssget"



     (setq sp (vlax-ename->vla-object (cdr (assoc 330 (entget (ssname s 0))))))
     (foreach l (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
       (mapcar '(lambda (x)
              (and (not (vl-position x tmp))
               (setq tmp (cons x tmp))

               (vlax-invoke sp 'addsphere x spherenum)
              )
            )
           (list (vlax-curve-getstartpoint l) (vlax-curve-getendpoint l))
       )
     )
    )
  )
  (princ)
)
(vl-load-com)

 

Link to comment
Share on other sites

Try "*line" be aware that is lines polylines and 3dpolylines. Also  "*line,arc" note the use of a comma "*line,arc,circle" "layer1,layer2,Layer3"

  • Agree 1
Link to comment
Share on other sites

  • 1 month later...

Hey Big Al.

Thanks again for the previous help. I'm now trying to exclude any 3D Sphere found within my selection set.

When I select everything, the code fails if if finds any 3D Sphere for some reason.

I want lines arcs and circles but not 3D spheres selected so it wont kill the code.  I'm removing the spheres from my selection set using ssdel... but not working.

 

(setq delsphere (ssget "_X" '((0 . "sphere")))); select all Spheres

(setq mpth (ssget '((0 . "*line,arc,circle"))); select all Lines, Arcs and circles
cntr 0
)

(ssdel delsphere mpth); remove spheres from the selection set that has Lines Arcs and Circles


 

 

Not working so I know I'm not doing this the right way.  Is there an easier way to just not have the 3D sphere in the selection set to begin with?

Thanks!

Link to comment
Share on other sites

wouldnt spheres be 3DSOLID's?
Also when you get your selectionset using (ssget '((0 . "*line,arc,circle"))) it shouldnt even select them in the first place.
 

Link to comment
Share on other sites

You would need to select by Solid Type = sphere?

 

Can you post the .dwg? 

 

As mentioned, why are they in the selection set?

Link to comment
Share on other sites

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