Jump to content

AutoLISP: Help for beginner


luiscarneirorm

Recommended Posts

Hi everyone.

 

I am developing an application for AutoCAD, and need a routines in AutoLISP, or a SCRIPTs for autocad I do the following:

 

Select the entities that limit one or more Hatchs ...

 

Select a different entities with the line width greater than a certain value...

 

Thanks in advance

Link to comment
Share on other sites

  • Replies 65
  • Created
  • Last Reply

Top Posters In This Topic

  • luiscarneirorm

    33

  • BlackBox

    12

  • Lee Mac

    11

  • Tharwat

    5

Top Posters In This Topic

Posted Images

To get all hatches in a drawing .

 


(setq htch (ssget "_x" '((0 . "HATCH")))) [/Code]

And to get lines that are equal to a specific length (in my example the length is 5.0)

 

[Code]
(defun c:test (/ ss i sset e)
(if
(setq ss (ssget "_x" '((0 . "LINE"))))
(repeat
(setq i (sslength ss))
(setq sset (ssname ss (setq i (1- i))))
(setq e (entget sset))
(if (not
(eq (distance (cdr (assoc 10 e)) (cdr (assoc 11 e))) 5.0)
)
(ssdel sset ss)
)
)
(princ)
)
(sssetfirst nil ss)
(princ)
)
[/Code]

[b]Tharwat[/b]

Link to comment
Share on other sites

To get all hatches in a drawing .

 


(setq htch (ssget "_x" '((0 . "HATCH")))) [/Code]

 

I do not want to select the hatchs, but the lines that limit

 

 

And to get lines that are equal to a specific length (in my example the length is 5.0)

 

[Code]
(defun c:test (/ ss i sset e)
(if
(setq ss (ssget "_x" '((0 . "LINE"))))
(repeat
(setq i (sslength ss))
(setq sset (ssname ss (setq i (1- i))))
(setq e (entget sset))
(if (not
(eq (distance (cdr (assoc 10 e)) (cdr (assoc 11 e))) 5.0)
)
(ssdel sset ss)
)
)
(princ)
)
(sssetfirst nil ss)
(princ)
)[/Code]

[b]Tharwat[/b]

 

and here the goal is to filter lines, arcs, etc., with lineweigth ([b]not lenght[/b]) greater than 0.5 for example.

 

sorry my bad english :oops:

 

Thanks...

Edited by luiscarneirorm
Link to comment
Share on other sites

That's also not a line , it is a circle isn't it ?

 

yes. is this hatch limit of what I want to select

Link to comment
Share on other sites

I believe he is wanting to select the hatch BOUNDARY.

 

He is also wanting to select all entities with a LINEWIDTH greater than a specified WIDTH.

 

QSELECT will do both.

Link to comment
Share on other sites

I believe he is wanting to select the hatch BOUNDARY.

 

He is also wanting to select all entities with a LINEWIDTH greater than a specified WIDTH.

 

QSELECT will do both.

 

yes, that's what I want, but this function does not allow me to do this

Link to comment
Share on other sites

Why does Qselect not work?

 

You must want something more.

 

I do not find the settings for this filter with the QSELECT

Link to comment
Share on other sites

  • 1 month later...

My goal was to do that, but with a lisp routine, and not just for polylines, but for all types of entities.

 

And isn't the width, but yes the lineweigth.

 

Sorry the Inglish... :oops:

Link to comment
Share on other sites

QSELECT will select polylines with a specified *global width*

 

[ATTACH=CONFIG]29701[/ATTACH]

 

You also have greater than, not equal, = equal and select all options for the operators.

Link to comment
Share on other sites

My goal was to do that, but with a lisp routine, and not just for polylines, but for all types of entities.

 

Sorry the Inglish... :oops:

 

No worries; try this:

 

(defun c:SBW ()(c:SelectByWidth))
(defun c:SelectByWidth ( / width ss)
 (if (and (setq width (getreal "\nEnter width: "))
          (setq ss (ssget "_x" (list (cons 43 width)))))
   (sssetfirst nil ss)
   (prompt "\n** Nothing selected ** "))
 (princ))

Link to comment
Share on other sites

Wait... I just saw that you revised your post:

 

And isn't the width, but yes the lineweigth.

 

So you want to select by LINEWIEGHT, and not by GLOBAL WIDTH? :unsure:

Link to comment
Share on other sites

Your English is good.

 

Are the ENTITIES (the objects drawn in modelspace) assigned an individual lineweight, or are they all set to ByLayer, and the LAYER is assigned a lineweight?

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