Hopefully this is a quick one. I am using autocad electrical 2011.
In my lisp i am inserting a wire:
(c:wd_wire (list 17.0 21.75) (list 17.0 0.75) "RED-14AWG")
Then i put a wire number on it
(c:wd_putwnxyf (list 17.0 10.0) "X1").
My problem is i want this to be put on the other side of the wire. Autocad electrical has a command AEflipwireno
I can type onto the command line
aeflipwireno, then type in last and it works. I am trying to incorporate this into my lisp, this way doesn't work so I tried this:
(works through command line by copying and pasting but not in lisp), the lisp bypasses these lines and goes to the next command.
(setq vgao (vlax-get-acad-object))
(setq vgad (vla-get-activedocument vgao))
(vla-sendcommand vgad (strcat "aeflipwireno\rlast\r "))
So I tried this by reading other posts and it errors out:
(vla-sendcommand vgad (strcat "(command \"aeflipwireno\")\n" last "\n"))
; error: bad argument type: stringp #<SUBR @0000000029f5e818 LAST>
any ideas?
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Untested... try
(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "aeflipwireno all \r")
EDIT:if it does not work properly, type the command onto the command line, after the command finished press F2 and copy/paste the command prompts here...
HTH
Henrique
It seems that the getkword function does not finish, try
(initget 1 "Yes No")
(setq 120answer (getkword "\nDo you want to insert 120VAC Incoming Power Circuit [Yes/No]: "))
and test for "Yes No", even the user enter "Yes No" with capital letters, the getkword function will return "Yes or No" as they are defined at the initget function...
Henrique
@gcsjlewis wrote:
...
The getkword works the way I want it. The aeflipwireno needs to execute before the getkword does (right after I insert the wire) but those 2 commands are getting crossed somehow
...
Only testing for, try
(c:wd_wire (list 17.0 21.75) (list 17.0 0.75) "RED-14AWG") (princ "\n creat wire (start end layer)") (c:wd_putwnxyf (list 17.0 10.0) "X1") (princ "\n puts wire number \"X1\" on it") (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "aeflipwireno\rlast\r") (princ "\n flip side") (c:wd_wire (list 30.0 21.75) (list 30.0 0.75) "WHITE-14AWG") (princ "\n creat wire (start end layer)") (c:wd_putwnxyf (list 30.0 10.0) "N") (princ "\n puts wire number \"N\" on it, this does not need to flip")
Henrique
Sorry if you have already gotten this message, i haven't seen it post yet
Here’s my entire command line results. It put the wires & numbers in, but it doesn’t flip that one number
Command: (c:wd_wire (list 17.0 21.75) (list 17.0 0.75) "RED-14AWG")
Command: (princ "\n creat wire (start end layer)")
creat wire (start end layer)"\n creat wire (start end layer)"
Command: (c:wd_putwnxyf (list 17.0 10.0) "X1") _.CLAYER
Enter new value for CLAYER <"SYMS">: SYMS
Command: _.INSERT Enter block name or [?]: WD_WNV Specify insertion point or
[Basepoint/Scale/X/Y/Z/Rotate]:
Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>:
1.000000000000000 Enter Y scale factor <use X scale factor>:
Specify rotation angle <0>:
Command: _.CLAYER
Enter new value for CLAYER <"SYMS">: SYMS
Command: <Entity name: 7ffff7712e0>
Command: (princ "\n puts wire number \"X1\" on it")
puts wire number "X1" on it"\n puts wire number \"X1\" on it"
Command: (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object))
"aeflipwireno\rlast\r") nil
Command: (princ "\n flip side")
flip side"\n flip side"
Command: (c:wd_wire (list 30.0 21.75) (list 30.0 0.75) "WHITE-14AWG")
Command: (princ "\n creat wire (start end layer)")
creat wire (start end layer)"\n creat wire (start end layer)"
Command: (c:wd_putwnxyf (list 30.0 10.0) "N") _.CLAYER
Enter new value for CLAYER <"SYMS">: SYMS
Command: _.INSERT Enter block name or [?] <WD_WNV>: WD_WNV Specify insertion
point or [Basepoint/Scale/X/Y/Z/Rotate]:
Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>:
1.000000000000000 Enter Y scale factor <use X scale factor>:
Specify rotation angle <0>:
Command: _.CLAYER
Enter new value for CLAYER <"SYMS">: SYMS
Command: <Entity name: 7ffff7713c0>
Command: (princ "\n puts wire number \"N\" on it, this does not need to
flip")aeflipwireno
puts wire number "N" on it, this does not need to flipnil
Command: last
Unknown command "LAST". Press F1 for help.
I am seeing that the vla-sendcommand is the last command sended to the command line, regardless the place in the code...
Perhaps something like this will do the trick
(defun c:test () (vl-load-com) (defun test1 () (c:wd_wire (list 30.0 21.75) (list 30.0 0.75) "WHITE-14AWG") (c:wd_putwnxyf (list 30.0 10.0) "N") (princ) ) (c:wd_wire (list 17.0 21.75) (list 17.0 0.75) "RED-14AWG") (c:wd_putwnxyf (list 17.0 10.0) "X1") (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "aeflipwireno\rlast\r") (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "(test1)\r") (princ) )
HTH
Henrique
I also stuck on similar issue
in my case I need to insert electrical component and then add the electrical balloon to last insert part . this process repeat again for next component and respective balloon.
But lisp is insert all component first and add all balloon after that it create problem the same as you face. can you help me in that case bellow is my code.
(defun C:AddBlk (path Insertpt len num / new_entname x1 x2 y1 y2) (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")) ) (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) );Defun (DEFUN c:Test() (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) )