• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

sequential numbering wires of an electrical scheme

  • Thread starter Thread starter salmozzo
  • Start date Start date

salmozzo

Guest
Hello.
I am trying to fill out my function that I need to number the wires of an electrical schematic quickly.
I already have the whole program in mind, so I'm going to small steps and testing every inch of code because I don't know the wrong program even the simplest things.

in a few words the code does this:
select a point on autocad (input).
records the coordinates
adds to these coordinates of x and y numbers so as to identify the 4 points where they go to insert the text (wire numbering)
then insert the number (input)imposed the text to printmold the text processed in the 4 points found.

The final goal is:
I write 15.



No.

I came to this point:
(defun c:silpi4 ()
; set the 4 coordinates of the texts
(setq p0 (getpoint "\n click")); reference point (input)
(setq x_p1234 (+ 30 (car p0)));
(setq y_p1 (+ 80 (cadr p0)) ;coordinated y first point
(setq y_p2 (+ 75 (cadr p0)) ;coordinated y second point
(setq y_p3 (+ 70 (cadr p0)) ;coordinated y third point
(setq y_p4 (+ 65 (cadr p0)) ;coordinated y fourth point

; input number
(setq num (getint "\n enter a number"))

; set the 4 texts
(setq r_text "r")
(setq s_text "s")
(setq t_text "t")
(setq n_text "n")

;write the 4 texts
(command "text" (list x_p1234 y_p1) "2.5" "0" r_text ") ; write text in point 1
(command "text" (list x_p1234 y_p2) "2.5" "0" s_text") ; write text in point 2
(command "text" (list x_p1234 y_p3) "2.5" "0" t_text ") ; write text in point 3
(command "text" (list x_p1234 y_p4) "2.5" "0" n_text ") ; write text in point 4
then there are many other things I would like to add:
I've worked six hours for now. and it's about 1 hour and a half that I'm still finding the solution to merge r with 15
thanks to who can help me
 
oppuri

; impost 4 tei
(setq r _ text (strata "r" (rtos num 2 0))
(setq s _ text (tight "s" (rtos num 2 0))
(setq t _ text (tight "t" (rtos num 2 0))
(setq n _ text (strata "n" (rtos num 2 0))
 
Thank you.

(((((((((((((((((((((()))))
So I have to learn scripts and convert it into scripts.

do you have guides to recommend me?
 
a script is simply a set of commands as if you give them from the keyboard.
to match a number to a string with the script.
 
yesterday I tried to do something with scripts but not too much satisfaction. . .
I want to continue my function with lisp.

The last update is under the spoiler.
- inserted possibility to add a prefix
- added endless while cycle to increase the number of wire
Code:
(defun c:silpi7 ()
(setq pref (getstring "\n insert a prefix: ")
(setq num (getint "\n enter a number: (a) the first number

(while t; endless loop start

;; set the 4 coordinates of the texts
(setq p0 (getpoint "\n click")); reference point (input)
(setq x_p1234 (+ 10 (car p0)));
(setq y_p1 (+ 30 (cadr p0)) ;coordinated y first point
(setq y_p2 (- y_p1 5) ;coordinated y second point
(setq y_p3 (- y_p2 5) ;coordinated y third point
(setq y_p4 (- y_p3 5) ;coordinated y fourth point

;implementing the four texts
(setq r_text (strcat "r" pref (rtos num 2 0)))
(setq s_text (strcat "s" pref (rtos num 2 0)))
(setq t_text (strcat "t" pref (rtos num 2 0)))
(setq n_text (strcat "n" pref (rtos num 2 0)))

;(seq rest (rem num_2poli 3) ; phase calculation 2 poles

;; write the 4 texts
(command "text" (list x_p1234 y_p1) "2.5" "0" r_text ) ; write text in point 1
(command "text" (list x_p1234 y_p2) "2.5" "0" s_text ) ; write text in point 2
(command "text" (list x_p1234 y_p3) "2.5" "0" t_text ) ; write text in point 3
(command "text" (list x_p1234 y_p4) "2.5" "0" n_text ) ; write text in point 4

(setq num (+ num 1 )); increase the number for the next loop
)
)
At this point I would like to create an option to allow me to split my code into 2 options:
1) 4 poles, which I print the usual 4 threads r,s,t,n
(2) 2
here instead I want to print only r,n then sn then tn and then depart from r.

the text setting part there are:
When I'm in modalities, I'll start a new count "num_2poli"
which calculates the rest of the split with 3 to understand which stage between r,s,t I have to print
(setq rest (rem num_2poli 3))
the problem is to create the two options 4poli and 2poliThank you.
 
you have to activate a choice if translated literally means if
(initget "4poli" "2poli") ;; this allows to limit the input after the only 2 strings quoted or to the numbers 4 and 2(setq choice (getkword "type circuit: ")(if (= choice "2poli)
(progn)
all the list
);
);

(if (= choice "4poli)
(progn)
all the list
);
);
 
everything works perfectly thanks a thousand
The only correction I can do is that the command(initget "4poli" "2poli")
you put too many "(initget "4poli 2poli")
so it is correct
Code:
;I insert a number and add it to rstn progressively
;adjusted prefix
; other choice 2poli,3poli,4poli

(defun c:silpi7 ()
(setq pref (getstring "\n insert a prefix: (a) prefixed input
(setq num (getint "\n enter a number: (a) the first number
(setq num_2poli 0)

(while t; endless loop start

;; set the 4 coordinates of the texts
(setq p0 (getpoint "\n click")) ;input reference point
(setq x_p1234 (+ 10 (car p0)));
(setq y_p1 (+ 30 (cadr p0)) ;coordinated y first point
(setq y_p2 (- y_p1 4) ;coordinated y second point
(setq y_p3 (- y_p2 4) ;coordinated y third point
(setq y_p4 (- y_p3 4) ;coordinated y fourth point

;implementing the four texts
(setq r_text (strcat "r" pref (rtos num 2 0)))
(setq s_text (strcat "s" pref (rtos num 2 0)))
(setq t_text (strcat "t" pref (rtos num 2 0)))
(setq n_text (strcat "n" pref (rtos num 2 0)))

(initget "2poli 3poli 4polies")
(setq choice (getkword "type circuit: ")

(if (= choice "2poli")
(progn)
; phase 2 poles
(setq rest (rem num_2poli 3))
(setq num_2poli (+ num_2poli 1))
(cond)
((= rest 0)(setq 2poli_text r_text))
((= rest 1)(setq 2poli_text s_text))
((= rest 2)(setq 2poli_text t_text))
)
; write the 2 texts
(command "text" (list x_p1234 y_p2) "2.5" "0" 2poli_text ) ; write text in point 2
(command "text" (list x_p1234 y_p3) "2.5" "0" n_text ) ; write text in point 3
)

);

(if (= choice "3poli")
(progn)
; write the 3 texts
(command "text" (list x_p1234 y_p1) "2.5" "0" r_text ) ; write text in point 1
(command "text" (list x_p1234 y_p2) "2.5" "0" s_text ) ; write text in point 2
(command "text" (list x_p1234 y_p3) "2.5" "0" t_text ) ; write text in point 3
)
);

(if (= choice "4poli")
(progn)
;; write the 4 texts
(command "text" (list x_p1234 y_p1) "2.5" "0" r_text ) ; write text in point 1
(command "text" (list x_p1234 y_p2) "2.5" "0" s_text ) ; write text in point 2
(command "text" (list x_p1234 y_p3) "2.5" "0" t_text ) ; write text in point 3
(command "text" (list x_p1234 y_p4) "2.5" "0" n_text ) ; write text in point 4
)
);

(setq num (+ num 1 )); increase the number for the next loop
)
)
If you want to change parameters?
for example, the height of the text, or the coordinates. . .

at the beginning of the program I would like to have the opportunity to change these parametersbut having defauf values , in such a way as not to insert them at each opening of the command
Is that possible?
 
(setq htesto nil)
(initget 6)
(setq htesto (getreal "text height: <2.5> ")))
(if (= htesto nil) (setq htesto 2.50))
 
great
You helped me a lot.
This is the final result
Code:
;I insert a number and add it to rstn progressively
;adjusted prefix
; other choice 2poli,3poli,4poli
; additional possibility to change text height
; additional possibility to change the initial phase of the 2 poles
;Add change initial parameters with default preset values

(defun c:silpi8 ()

(Sectq pref nil)
(setq pref (getstring "prefectious: <vuoto> ")
(if (= pref nil) (setq pref")

(setq num nil)
(initget 6)
(setq num (getint "numbering starts from: <0> "))
(if (= num nil) (setq num 0)

(setq phase_2poli nil)
(initget "1 2")
(setq phase_2poli (getkword "\n initial phase 2 poles: <r> Press 1 per phase s; press 2 per stage t))
(if (= phase_2poli nil) (setq phase_2poli 0)

(setq htesto nil)
(initget 6)
(setq htesto (getreal "text height: <2.5> ")))
(if (= htesto nil) (setq htesto 2.50))

(while t; endless loop start

;; set the 4 coordinates of the texts
(initget 9 )
(setq p0 (getpoint "\n click")) ;input reference point
(setq x_p1234 (+ 10 (car p0)));
(setq y_p1 (+ 30 (cadr p0)) ;coordinated y first point
(setq y_p2 (- y_p1 (* htesto 1.6)));
(setq y_p3 (- y_p2 (* htesto 1.6));
(setq y_p4 (- y_p3 (* htesto 1.6));

;implementing the four texts

(setq r_text (strcat "r" pref (rtos num 2 0)))
(setq s_text (strcat "s" pref (rtos num 2 0)))
(setq t_text (strcat "t" pref (rtos num 2 0)))
(setq n_text (strcat "n" pref (rtos num 2 0)))

(initget 9 "2poli 3poli 4poli");prevents the non-insertion of the type of circite
(setq choice (getkword "type circuit: ")

(if (= choice "2poli")
(progn)
; phase 2 poles
(seq rest (rem phase_2poli 3))
(setq phase_2poli (+ phase_2poli 1))
(cond)
((= rest 0)(setq 2poli_text r_text))
((= rest 1)(setq 2poli_text s_text))
((= rest 2)(setq 2poli_text t_text))
)
; write the 2 texts
(command "text" (list x_p1234 y_p2) htesto "0" 2poli_text ) ;write text in point 2
(command "text" (list x_p1234 y_p3) htesto "0" n_text ) ;write text in point 3
)

);

(if (= choice "3poli")
(progn)
; write the 3 texts
(command "text" (list x_p1234 y_p1) htesto "0" r_text ) ;write text in point 1
(command "text" (list x_p1234 y_p2) htesto "0" s_text ) ;write text in point 2
(command "text" (list x_p1234 y_p3) htesto "0" t_text ) ;write text in point 3
)
);

(if (= choice "4poli")
(progn)
;; write the 4 texts
(command "text" (list x_p1234 y_p1) htesto "0" r_text ) ;write text in point 1
(command "text" (list x_p1234 y_p2) htesto "0" s_text ) ;write text in point 2
(command "text" (list x_p1234 y_p3) htesto "0" t_text ) ;write text in point 3
(command "text" (list x_p1234 y_p4) htesto "0" n_text ) ;write text in point 4
)
);

(setq num (+ num 1 )); increase the number for the next loop
)
) </r></vuoto>
the last modification I made was this below, it allows me not to press enter if I didn't click before (before it crashed the function) (initget 9) ;prevents non-insertion of coordinates
(setq p0 (getpoint "\n click")) ;input reference point
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
ciao
Back
Top