create two Macro

create two Macro

Michael_Ru2
Explorer Explorer
558 Views
13 Replies
Message 1 of 14

create two Macro

Michael_Ru2
Explorer
Explorer

Hi there,

 

Can you please create two Macro for AutoCAD Electrical?

1. Select all revision clouds.
2. Delete all revision clouds.
They are two separate Macros, thank you very much in advance.

0 Likes
559 Views
13 Replies
Replies (13)
Message 2 of 14

Sea-Haven
Mentor
Mentor

A revision cloud is a Lwpolyline but it contains xdata with the "revisioncloud", a normal LWPOLYLINE may not have Xdata.

 

(defun c:getXData ( / ename edata )
  (if (setq ename (car (entsel "\nSelect entity to read xdata: ")))
    (progn
      (setq edata (entget ename '("*")))
      (if (setq xdata (cdr (assoc -3 edata)))
        (foreach item xdata
          (print item)
        )
        (princ "\nEntity has no xdata.")
      )
    )
  )
  (princ)
)

 

Result of picking a revcloud, ("RevcloudProps" (1070 . 0) (1040 . 25.0)) so you could check the car of item and if exists then delete object.

Message 3 of 14

Michael_Ru2
Explorer
Explorer

Hi there,

 

Is it possible to write it in Macro? Many thanks.

 

 

0 Likes
Message 4 of 14

didier_lourdelle
Advocate
Advocate

; Define a function named c:SelectRevCloud to select and highlight revision clouds
(defun c:SelectRevCloud ( / sel i ent vlaEnt )
; Create a selection set of all polylines that are revision clouds
(setq sel (ssget "_X" '((0 . "LWPOLYLINE") (-3 ("RevcloudProps")))))
; Check if the selection set is not empty
(if sel
; Start a block of code
(progn
; Initialize the counter to zero
(setq i 0)
; Loop through each item in the selection set
(while (< i (sslength sel))
; Get the entity name at index i
(setq ent (ssname sel i))
; Convert the entity name to a VLA object
(setq vlaEnt (vlax-ename->vla-object ent))
; Highlight the entity
(vla-highlight vlaEnt :vlax-true)
; Increment the counter
(setq i (1+ i))
)
)
)
; Suppress the return value from being printed
(princ)
)

; Define a function named c:EraseRevCloud to erase revision clouds
(defun c:EraseRevCloud ( / Js )
; Create a selection set of all polylines that are revision clouds
(setq Js (ssget "_X"
'(
(0 . "LWPOLYLINE")
(-3
("RevcloudProps")
)
)
))
; Check if the selection set is not empty
(if Js
; Erase all entities in the selection set
(command "_erase" Js "")
)
; Suppress the return value from being printed
(princ)
)

EESignature



Didier Lourdelle Consultant, Formateur & Développeur CAO/DAO EDWGPROS

Expertises : AutoCAD, AutoCAD LT, AutoCAD Electrical
Langages : VB.NET, Visual LISP, VBA, Diesel (Direct Interpretively Evaluated String Expression Language)
Base de données relationnelle : Microsoft Access, SQL Server, MySQL
Environnements de développement : Microsoft Visual Studio, Visual Studio Code, Editeur Visual LISP
Utilisations :AutoCAD MAP, Civil 3D, AutoCAD Architecture, AutoCAD MEP, Plant 3D, Civil 3D, RasterDesign, VehicleTracking, Autodesk Recap, Fusion 360, NavisWorks, Revit
Mon blog : Trucs & Astuces Sur AutoCAD LT !

 

Message 5 of 14

paullimapa
Mentor
Mentor

Why a macro?  If you have AutoCAD LT that’s at least 2024 lisp is supported 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 6 of 14

Michael_Ru2
Explorer
Explorer

Macro is simple and quick, like AutoCAD command. If it is a lisp, I need to pre-load it and run it. If there are lots pre-load lisps, I am not sure if it affects the quality and speed. Thanks a lot!

0 Likes
Message 7 of 14

paullimapa
Mentor
Mentor

Now-a-days with the hardware's processing speeds along with 64 bit OS, pre-loading lisp is a breeze and does not impact the speed at all.

Just give it a try and you'll see. But as far as I know, there are no macros which btw is a sequence of built-in AutoCAD commands that can achieve what you're after.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 8 of 14

Michael_Ru2
Explorer
Explorer

I will try it, thanks.

0 Likes
Message 9 of 14

paullimapa
Mentor
Mentor

the first one only lets you select one object while the second one you can select multiple but neither handles locked layers so just remember to unlock those layers which with the revision clouds before proceeding with the lisp.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 10 of 14

Michael_Ru2
Explorer
Explorer

many thanks! 🙂

0 Likes
Message 11 of 14

paullimapa
Mentor
Mentor

you are welcome...cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 12 of 14

Michael_Ru2
Explorer
Explorer

Hi there,

 

Is it possible to automatically select revision clouds with manual selection after load lisp? many thanks.

0 Likes
Message 13 of 14

Sea-Haven
Mentor
Mentor

Loading a lisp, there is a function called "Autoload" in lisp, you load one lisp file at start up and inside it is all the lisps that you MAY want to run, when you type in the command call for that lisp it is then loaded. For me I use pop menus. You use Appload to save your custom lisp into the startup suite.

(autoload "COPY0" '("COPY0"))
(autoload "COPYCOMMAND" '("ZZZ"))
(autoload "COVER" '("COVER"))
(autoload "DIMFLIP" '("DIMFLIP"))
(autoload "DRAWXFALL" '("DRAWXFALL"))
(autoload "DRAWPIPE" '("DRAWPIPE"))
(autoload "EDITRL" '("EDITRL"))
(autoload "EDITXSECT" '("EDITXSECT"))
(autoload "EDITLSECT" '("EDITLSECT"))
(autoload "FLIPLINE" '("FLIPLINE"))
(autoload "Goto-LAYOUT" '("GOTO"))

 

Message 14 of 14

Michael_Ru2
Explorer
Explorer

Thanks a lot!

0 Likes