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

using vla-sendcommand

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
gcsjlewis
4034 Views, 10 Replies

using vla-sendcommand

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?

10 REPLIES 10
Message 2 of 11
hmsilva
in reply to: gcsjlewis

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

EESignature

Message 3 of 11
gcsjlewis
in reply to: hmsilva

The command doesn't recognize "all". It does "last" so:

(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "aeflipwireno last \r") works, but only through the command line not lisp.

Here's the bit of my code where I have it

(c:wd_wire (list 17.0 21.75) (list 17.0 0.75) "RED-14AWG"); creat wire (start end layer)
(c:wd_putwnxyf (list 17.0 10.0) "X1"); puts wire number "X1" on it
(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "aeflipwireno last \r"); flip side
(c:wd_wire (list 30.0 21.75) (list 30.0 0.75) "WHITE-14AWG"); creat wire (start end layer)
(c:wd_putwnxyf (list 30.0 10.0) "N"); puts wire number "N" on it, this does not need to flip

The problem is, the following is prompted before the above happens:
(initget 1 "Yes No")
(setq 120answer (strcase (getkword "Do you want to insert 120VAC Incoming Power Circuit [Yes/No]: ") nil))(princ)

Command line results:
Command: Do you want to insert 120VAC Incoming Power Circuit [Yes/No]:
aeflipwireno
Invalid option keyword.
Do you want to insert 120VAC Incoming Power Circuit [Yes/No]: last
Invalid option keyword.
Do you want to insert 120VAC Incoming Power Circuit [Yes/No]:


Hope this makes sense.

________________________________
The information contained in this message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately, and delete the original message.
Message 4 of 11
hmsilva
in reply to: gcsjlewis

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

EESignature

Message 5 of 11
gcsjlewis
in reply to: hmsilva

If I comment out the

(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "aeflipwireno " "last " )) command

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


________________________________
The information contained in this message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately, and delete the original message.
Message 6 of 11
hmsilva
in reply to: gcsjlewis

Type the aeflipwireno command onto the command line, after the command finished press F2 and copy/paste the command prompts here...

Henrique

EESignature

Message 7 of 11
hmsilva
in reply to: gcsjlewis


@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

EESignature

Message 8 of 11
gcsjlewis
in reply to: gcsjlewis

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.

 

Message 9 of 11
hmsilva
in reply to: gcsjlewis

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

EESignature

Message 10 of 11
gcsjlewis
in reply to: hmsilva

It's not working. I will mess around with it tonight. . .i kinda see where you are going. I'll let you know. Thanks!

________________________________
The information contained in this message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately, and delete the original message.
Message 11 of 11

@hmsilvaand @gcsjlewis

 

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)

  
  )

 

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

Post to forums  

Autodesk Design & Make Report

”Boost