Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using AE (AutoCAD Electrical) commands in LISP.

14 REPLIES 14
Reply
Message 1 of 15
sonny3g
4018 Views, 14 Replies

Using AE (AutoCAD Electrical) commands in LISP.

I would like to use the next (AENEXT) and previous (AEPREV) commands in a lisp routine.  Both commands work fine when typed in the command line, but will not run when called (COMMAND "AENEXT") in lisp.  Can anyone help me with this?

 

Thanks

 

Scott

Scott G. Sawdy
scott.sawdy@bluecoyotecad.com
14 REPLIES 14
Message 2 of 15
stevor
in reply to: sonny3g

You can try the standard command syntax: (c:AENEXT) for starters.

 

Also, make sure they are actually loaded before trying your code, as some functions load from others.

 

S
Message 3 of 15
sonny3g
in reply to: stevor

Thanks, what I was doing wrong was leaving out the parenthesis and the C:.  Made that change and it works great.

 

Thanks again.

 

Scott

Scott G. Sawdy
scott.sawdy@bluecoyotecad.com
Message 4 of 15
darrell.l.gregg
in reply to: sonny3g

I am encountering the same issue, using the (c:AEWIRENOLEADER) works to get the command to run, but I want it to automatically go into the "collapse" mode. I am having a hard time coding in how to get the command modifiers to work. I have trid a few variations on where to put the "C" I need to go into collapse mode... It seems to ignore anything after the command call (C:aewirenoleader)....

 

 

Message 5 of 15
hmsilva
in reply to: darrell.l.gregg

darrell.l.gregg,

I don't have AE to testing, but maybe something like

 

(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "AEWIRENOLEADER C"))


try, and tell me what the result.

 

Henrique

EESignature

Message 6 of 15
darrell.l.gregg
in reply to: sonny3g

I had to modify the command slightly:

(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "AEWIRENOLEADER C\n")).

added the <\n> to make it go into that mode with a pick box ready to start picking object.

 

I have much to learn about these commands "vla"...

 

Thank you.

Message 7 of 15
hmsilva
in reply to: darrell.l.gregg

You're welcome, darrell.l.gregg

glad I could help

 

Henrique

EESignature

Message 8 of 15
pbretin
in reply to: sonny3g

Hello,

 

I want to do the same thinks with AEHIDEATTRIB command

 

I do this command line (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "AEHIDEATTRIB TOUT  ")), but i don't kown, how to select TAG2 automatically in the window.

 

Do can help me ?

 

Philippe.

Message 9 of 15
darrell1gregg
in reply to: pbretin

sendcommand isn't going to be able to do what you want to do.

 

 

You'll have to cycle through the entity database with the entnext function and find all dxf codes (0 . "ATTRIB"), then look for the dxf code "2" for the "name", will look like this (2 . "TAG2") on that attrib. Once you have that entity you use the substr to put the new value onto the list, then use entmod to change the entity in the database.

 

 

you can do the same thing with active-x as well.

 

Message 10 of 15
darrell.l.gregg
in reply to: pbretin

Philippe,

this will do the trick for you...

 

I don't know how much AutoLISP you know... let me know if you need help with using the source code below.

 

Source code for making TAG2 attribute invisible for all objects in dwg follows:

 

(defun ht2 ( / c_ent c_ent_data ent_handle handle_list)
  (setq c_ent (entnext));get the first entity in the database
  (setq c_ent_data (entget c_ent));get the data for the entity
  (if;if the entity is an attribute, and has name "tag2"
    (and;is the entity an attribute with name tag2?
      (equal "ATTRIB" (cdr (assoc 0 c_ent_data)))
      (equal "TAG2" (cdr (assoc 2 c_ent_data)))
      );end and
    (progn;then...
      (setq ent_handle (cdr (assoc 5 c_ent_data)));get the entity handle
      (setq handle_list (cons ent_handle handle_list));add the handle to the list of handles
      );end progn
    );end if
  (while
    (setq c_ent (entnext c_ent));get the next entity in the database
    (setq c_ent_data (entget c_ent));get the entity data list
  (if;if the entity is an attribute, and has name "tag2"
    (and;is the entity an attribute with name tag2?
      (equal "ATTRIB" (cdr (assoc 0 c_ent_data)))
      (equal "TAG2" (cdr (assoc 2 c_ent_data)))
      );end and
    (progn;then...
      (setq ent_handle (cdr (assoc 5 c_ent_data)));get the entity handle
      (setq handle_list (cons ent_handle handle_list));add the handle to the list of handles
      );end progn
    );end if
    );end while
  (foreach enthandle handle_list
    (progn;then do all this stuff
      (setq c_ent_data (entget (handent enthandle)));get the entity data for the current item in list
      (setq c_ent_data (subst (cons 70 1) (cons 70 (cdr (assoc 70 c_ent_data))) c_ent_data));create the new entity data list
      (entmod c_ent_data);modify the entity
      );end progn
    );end foreach
  (princ "\nAll TAG2 attributes set to invisible");print message to screen...comment out this line to prevent command line output.
  (princ);end quitely
  );end defun

Message 11 of 15
email2dineshpawar
in reply to: sonny3g

@stevor@sonny3g@darrell.l.gregg@hmsilva

 

I have same issue with Balloon command in ACADE 2016.
I want to insert balloon to object with lisp and my code is as follow but it not work here is my code.

 

(C:AEBALLOON Obj1 pt1 pt2 "")
;pt1 and pt2 are point
;obj1 as object

 


but it so error. can you suggest proper method for selecting Balloon command. 

 

Thank in advance.

 

email2dineshpawar@gmail.com

Message 12 of 15

Ok, that's a tough one.

I am pretty sure you can't use vla-sendcommand because entity names are not strings and can't be passed as strings (I tried, but I can't find a method to make that work).

 

I next tried a selection set:

(setq obj (ssget ":E" '((0 . "INSERT")(8 . "PSYMS"))))
(setq pt1 (getpoint "start of leader"))
(setq pt2 (getpoint "end of leader"))

 

to setup the variables and then tried this to pass them to the commandline:

(vl-cmdf "(C:aeballoon)" obj pt1 pt2)

AEBALLOON doesn't see the selection set, it won't accept it. and I get the "(C:aeballoon) LISP command is not available". error

 

I suspect this doesn't work because one is trying to "re-enter LISP" by using LISP to control AEBALLOON.

Also AEBALLOON may pop up a window if bubbles already exist and that would blow up any LISP you would be trying to do anyway.

 

 

 

I can offer a possible other solution but it would take a lot more work...

You may be able to just do it all yourself.

Bubble information is stored as Xdata on the blocks and bubbles. Once you run the bubble resequence command that Xdata is populated.

Read the Xdata on the panel footprint block, find the bubble block on your system, insert that, update it's data (and Xdata), then attach an arrowhead (acade uses a "solid") then attach a leader (acade uses just a "line").

 

There is a little tool in ACADE that allows you to look at the Xdata rather easily, on the project tab, other tools, Xdata editor.

VIA_WD_BALLPTR

VIA_WD_HDL

VIA_WD_ITEM

WD_P_ITEM

And a few more... but that is where you may need to go if you really want to do what I think you want to do.

 

Of course none of that  would be detected by the ACADE system code (reactors to let ACADE know what you are doing so it can update the database).

A project refresh might make all that stick though. Or it really won't matter because the database is already up to date due to the resequence.

 

 

There may be another solution but I just don't have much time right now to do anymore research.

Message 13 of 15
Message 14 of 15

 

This is my code for inserting part and add balloon to it in ACADE 16 but it have problem that it is run good for 1 st block but for next block balloon show error. can you suggest solution


(defun AddBlk(path Insertpt len num / new_entname x1 x2 y1 y2) (setq new_entname (c:wd_insert_elect_block path Insertpt 1 1.0)) (c:wd_modattrval new_entname "P_ITEM" (itoa num) 1) (setq inspoint (cdr (assoc 10 (entget new_entname)))) (setq x1 (car inspoint)) (setq y1 (car (cdr inspoint))) (setq x2 (+ (car inspoint) len)) (setq y2 (+ (car (cdr inspoint)) 0)) (Add_balloon x1 y1 x2 y2) (getvar 'viewctr) (princ) );Defun (defun Add_balloon( x1 y1 x2 y2) (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "AEballoon LAST\n" (rtos x1) "," (rtos y1) "\n" (rtos x2) "," (rtos y2) "\n\n\n")) ) (defun c:test() (setq pt (list 10 10)) (AddBlk "D:/Componants/PGL_APN_FU40.dwg" (list 0 0) -30 1) (AddBlk "D:/Componants/PGL_CFL_CAT_40_T.dwg" (list 0 150) 30 2) ;(AddBlk "D:/Componants/PGL_ABB_PS2_12.dwg" (list 10 20) -10) )

 

Message 15 of 15

What is the error you are getting?

 

Have you tried using VLIDE to step through and test your code?

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost