TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: diarmuid on June 07, 2023, 04:41:48 AM

Title: AutoCAD Line length ssget issue.
Post by: diarmuid on June 07, 2023, 04:41:48 AM
Hi,

I'm currently tidy up some drawings that had to be exported from Revit to AutoCAD.  I dont have the original Revit model to redo the export, so i need to tidy up the AutoCAD drawings to the client CAD standard.  So using lisp, i'm moving text at a particular height to a specific layer, hatch to hatch types to various hatching layers.  One issue im having is i'm trying to capture lines (they are sides of a hexagonal callout that was used.)  and there are hundreds of them per drawing and i wish to grab them using ssget and put them on a layer called callout.  for some reason im not having any luck. each of these lines are 56.2500mm in length.

This is my code, but it is not selecting any lines.  Am i missing something?

(defun c:SelectLinesByLength (/ SL1 ss)
  (setq SL1 56.250) ; Change the length value as needed
  (setq ss (ssget "_X" (list (cons 0 "LINE") (cons 40 SL1))))
  (command "_change" SL1 "" "Properties" "layer" "Detail" "ltype" "bylayer" "")
  (princ)
)

Any help on this would be greatly appreciated.
Regards
Diarmuid
Title: Re: AutoCAD Line length ssget issue.
Post by: dwaschnia on June 07, 2023, 06:32:02 AM
typo:
Title: Re: AutoCAD Line length ssget issue.
Post by: BIGAL on June 07, 2023, 07:56:32 PM
I am pretty sure can not use (cons 40 rather you have to get all lines and then compare is line length = SL1

Use equal function (equal len 56.25 1e-06) this allows for rounding up to 6 decimal places.