AutoCAD Electrical Forum
Welcome to Autodesk’s AutoCAD Electrical Forums. Share your knowledge, ask questions, and explore popular AutoCAD Electrical topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Circuit Builder Help! - Running non-API Lisp programs

8 REPLIES 8
Reply
Message 1 of 9
pjfontes
982 Views, 8 Replies

Circuit Builder Help! - Running non-API Lisp programs

I'll have to admit, I'm a little over my head as I'm more comfortable programming in VBA. ACADE, LISP and API calls are new to me - hopefully someone at Autodesk can help me out.

The objective: I need to be able to draw a Wire from one Node to another Node with Circuit Builder.

There are cases where using ace_cb_stretch_wire_connect can not accomplish what we need because the _WIRESKIP=n value is not always static.

Ok, no problem.. I can start by using the wd_wire API call:

(c:wd_wire (list 4 18) (list 4 12) nil )

Works great! But I'd like to be able to continue the theme of using nodes rather than absolute coordinates.

I took wd_wire one step further and had a lisp routine created to get me the coordinates of a node. (see attached)

(c:wd_wire (c:findnode "TEST1")(c:findnode "TEST2") nil)

This also works perfect while testing it in an open circuit drawing with some randomly placed nodes. However, when I use this command in ace_circuit_builder.xls I get an error:

Error: bad argument type: 2D/3D point: ("c:findnode" "F1" 0.0)

I'm guessing this has something to do with LISP rather than Circuit Builder but I don't understand why (c:wd_wire (c:findnode "TEST1")(c:findnode "TEST2") nil) works perfect when entered into the command prompt manually but not when used as a command within Circuit Builder.

Is this an issue with our programming or is circuit builder limited to running (reliably) with only API calls prefixed with "ace_cb_"?

Any help would be greatly appreciated.

PJF.
8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: pjfontes


I might be able to help but I am not clear on what
you are doing with the .lsp function findnode. What type of text do you put in
for the argument? Maybe if you included a picture of what you are trying to
accomplish I might better understand it. Also, can you show what you add to the
ace_circuit_builder.xls to call this function? Part of the error you are seeing,
("c:findnode" "F1" 0.0), makes it look like
there are too many arguments for your function. So maybe the syntax is just not
quite right in the spreadsheet.

 

Pat Murnen


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I'll
have to admit, I'm a little over my head as I'm more comfortable programming
in VBA. ACADE, LISP and API calls are new to me - hopefully someone at
Autodesk can help me out. The objective: I need to be able to draw a
Wire from one Node to another Node with Circuit Builder. There are cases where
using ace_cb_stretch_wire_connect can not accomplish what we need
because the _WIRESKIP=n value is not always static. Ok, no problem.. I can
start by using the wd_wire API call: (c:wd_wire (list 4 18) (list 4 12) nil )
Works great! But I'd like to be able to continue the theme of using nodes
rather than absolute coordinates. I took wd_wire one step further and had a
lisp routine created to get me the coordinates of a node. (see attached)
(c:wd_wire (c:findnode "TEST1")(c:findnode "TEST2") nil) This also works
perfect while testing it in an open circuit drawing with some randomly placed
nodes. However, when I use this command in ace_circuit_builder.xls I get an
error: Error: bad argument type: 2D/3D point: ("c:findnode" "F1" 0.0) I'm
guessing this has something to do with LISP rather than Circuit Builder but I
don't understand why (c:wd_wire (c:findnode "TEST1")(c:findnode "TEST2")
nil)
works perfect when entered into the command prompt manually but not
when used as a command within Circuit Builder. Is this an issue with our
programming or is circuit builder limited to running (reliably) with only API
calls prefixed with "ace_cb_"? Any help would be greatly appreciated. PJF.
Message 3 of 9
pjfontes
in reply to: pjfontes

Attached is a screen shot of a test that I did using the wd_wire API call together with the FindNode lisp program that we created. It works great.



I did a cut/paste of that exact command into ace_circuit_builder.xls and it echo'd this error:

Error: bad argument type: 2D/3D point: ("c:findnode" "TEST1" 0.0)Unknown



The node names are "F1" and "F2" I get this:

Error: bad argument type: 2D/3D point: ("c:findnode" "F1" 0.0)




Problem is that sometimes wires GFCT-A and GFCT-B are not there so I can't paste in a circuit with 'loops' already in place OR use a "_Wireskip=n". The root cause is that when you paste a circuit on top of a circuit ACADE wont put 'loops' in where they are required...
Message 4 of 9
Anonymous
in reply to: pjfontes


Well, I am not sure I can tell what is wrong
without your spreadsheet. If you don't want to post it, you can send it to me
directly at
href="mailto:pat.murnen@autodesk.com">pat.murnen@autodesk.com
. Are F1 and F2
the names of the blocks Circuit Builder is inserting at the place of the marker
block? If so can you include these blocks with the spreadsheet? I am just trying
to save time recreating what you are trying to do here.

 

The error indicates that it isn't actually running
the findnode function. It is using that value thinking it is part of the
coordinate for the wd_wire API call.

 

Pat Murnen


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Attached
is a screen shot of a test that I did using the wd_wire API call together with
the FindNode lisp program that we created. It works great.



I
did a cut/paste of that exact command into ace_circuit_builder.xls and it
echo'd this error:

Error: bad argument type: 2D/3D point: ("c:findnode"
"TEST1" 0.0)Unknown



The node names are "F1" and "F2" I get
this:

Error: bad argument type: 2D/3D point: ("c:findnode" "F1"
0.0)




Problem is that sometimes wires GFCT-A and GFCT-B are
not there so I can't paste in a circuit with 'loops' already in place OR use a
"_Wireskip=n". The root cause is that when you paste a circuit on top of a
circuit ACADE wont put 'loops' in where they are required...
Message 5 of 9
pjfontes
in reply to: pjfontes

Pat,

My apologies, I can understand how this can be confusing.

F1 and F2 (or TEST1 and TEST2) are the CODE values of arbitrary ace_cb_marker_block's that I am placing in the drawing. Their only purpose is to give the FindNode lisp routine a coordinate; a start point and end point of a "wire". The reason I'm using ace_cb_marker_block is to keep things consistent; circuit builder appears to ignore any unused marker blocks (which is great)

I will send you my ace_circuit_builder.xls as well as our 'master template' later today with clarification of exactly what we are trying to accomplish.

Paul F.
Message 6 of 9
Anonymous
in reply to: pjfontes


Per my email -

 



style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">this
evaluation of user lisp functions is not built in to Circuit Builder AcadE 2009
but is built into AcadE 2010. However, you can add a small function to 2009 to
get it to work. I've reproduced the function here -



style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">
 



style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">
style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"> 



style="COLOR: #1f497d">(defun c:ace_cb_eval ( a / )



style="COLOR: #1f497d">  ; This API call can be encoded into the Circuit
Builder spreadsheet. ARX will pass string "a"



style="COLOR: #1f497d">  ; and this eval function will parse it, replace '
char with " char, and then evaluate/execute



style="COLOR: #1f497d">  ; it.



style="COLOR: #1f497d">  ; Example 1: (c:ace_cb_eval "(setq overloads
1)")



style="COLOR: #1f497d">  ; Example 2: (c:ace_cb_eval "(if (= overloads
1)(c:ace_cb_insym #xyz nil 'HOL22' #scl 8 nil))")



style="COLOR: #1f497d">  ; In example #2, note that the "HOL22" is shown as
'HOL22'



style="COLOR: #1f497d">

 



style="COLOR: #1f497d">  (if (AND a (/= a ""))



style="COLOR: #1f497d">    (progn



style="COLOR: #1f497d">      ; Replace any ' character
found in string with double quote " character



style="COLOR: #1f497d">      (setq a (wd_fr_txt_replace
a "'" "\"" nil))



style="COLOR: #1f497d">      (eval (read a)) ; evaluate
the lisp expression



style="COLOR: #1f497d">  ) )



style="COLOR: #1f497d">  (princ)   



style="COLOR: #1f497d">)



size=2>
 



style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">
 


style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">


style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">This
can be saved in a .lsp file and should be added to the Startup loading
( APPLOAD add to the startup suite).



style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">
 



style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">And
the syntax of the call in the spreadsheet needs to change somewhat.  In the
spreadsheet change the line to the following –



style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">

 



style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">(c:ace_cb_eval
"(c:wd_wire (c:findnode 'TEST1') (c:findnode 'TEST2')
nil)")



style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">

 



style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">Notice
the whole line is “wrapped” in this new small function. This runs the user
function and exposes the value it returns to Circuit Builder. And notice the
single quotes around your arguments for the findnode function instead of double
quotes.



style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">

 



style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">Hope
this helps,



style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">Pat
Murnen


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Pat,
My apologies, I can understand how this can be confusing. F1 and F2 (or TEST1
and TEST2) are the CODE values of arbitrary ace_cb_marker_block's that I am
placing in the drawing. Their only purpose is to give the FindNode lisp
routine a coordinate; a start point and end point of a "wire". The reason I'm
using ace_cb_marker_block is to keep things consistent; circuit builder
appears to ignore any unused marker blocks (which is great) I will send you my
ace_circuit_builder.xls as well as our 'master template' later today with
clarification of exactly what we are trying to accomplish. Paul
F.
Message 7 of 9
pjfontes
in reply to: pjfontes

Replied Via E-Mail.

Thanks Again.
Message 8 of 9
Anonymous
in reply to: pjfontes

I am using AutoCad Electrical 2009. I have lisp routine that inserts a 3-pole combostarter much like the Ace_cb_multipole command does but I do not see any way of getting it called instead of the multipole command. Can you help?

Thanks
Johnny Mack Brown, Jr.
Controls Engineer
Message 9 of 9
Anonymous
in reply to: pjfontes

You would need to update the Circuit Builder spreadsheet to use your call
instead of the ace_cb_multipole call already in there. Also make sure that
your .lsp file is being loaded automatically each time a drawing is opened.
Since you are using AcadE 2009 you would also need to use the wrapper
described in the earlier post in this thread.

Pat Murnen

wrote in message
news:6226455@discussion.autodesk.com...
I am using AutoCad Electrical 2009. I have lisp routine that inserts a
3-pole combostarter much like the Ace_cb_multipole command does but I do not
see any way of getting it called instead of the multipole command. Can you
help?

Thanks
Johnny Mack Brown, Jr.
Controls Engineer

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

Post to forums  

Autodesk Design & Make Report

”Boost