LISP Update

LISP Update

BriamR
Advocate Advocate
676 Views
7 Replies
Message 1 of 8

LISP Update

BriamR
Advocate
Advocate

Hi community!

I have this lisp with release name ADD2OD2ATT that adds to the internal block type elements consecutive numerical consecutive blocks and the name of the block, the problem is that when there are a large number of blocks to process the execution takes considerably, how can I modify or improve it to run any number of blocks in a short time.

I appreciate any help you can give me, thanks.

 

0 Likes
Accepted solutions (1)
677 Views
7 Replies
Replies (7)
Message 2 of 8

Sea-Haven
Mentor
Mentor

Really not sure if searching a list is faster than cond the list has the ((efn "blah blah")("SP30-SR30" "TIPO_SENAL" 0 "SP-30/SR-30")............. so use a foreach to check. A sort of big task to make the list to check speed.

 

There are others here who may know if its worth while.

Message 3 of 8

ВeekeeCZ
Consultant
Consultant
Accepted solution

Ok, this should be faster.

 

BTW I know that the code comes from more resources therefore is inefficient... but WHY do YOU have like 10 items listed twice? Complaining about inefficiency but creating such a mess!? Programming is about consistency!!

 

 

(vl-load-com)

(defun c:AddTodatt ( / l s e o n i )
  
  (or *aoa-c* (setq *aoa-c* 0)) 						; initial default number lowered by 1.
  
  (setq l '(("DCH_N" . "DCH")
	    ("DOL_N" . "DOL")
	    ("CHEVRON_N" . "CHEVRON")
	    ("SI-05N" . "SI-05")
	    ("SI-07-a" . "SI-07")
	    ("SI-07AN" . "SI-07A")
	    ("SI-07ANPlaqueta" . "SI-07A PLAQUETA")
	    ("SI-07N" . "SI-07")
	    ("SI-07NF" . "SI-07")
	    ("SI08-Plaqueta-SI08Palqueta" . "SI-08 PLAQUETA/ SI-08 PLAQUETA")
	    ("SI08-Plaqueta-SI08PlaquetaN" . "SI-08 PLAQUETA/ SI-08 PLAQUETA")
	    ("SI-11_1" . "SI-11")
	    ("SI-11N" . "SI-11")
	    ("SI-25N" . "SI-25")
	    ("SI-27vc" . "SI-27")
	    ("SIC-02N" . "SIC-02")
	    ("SIC-03N" . "SIC-03")
	    ("SP23-SR30" . "SP-23/SR-30")
	    ("SP24-SR30" . "SP-24/SR-30")
	    ("SP25-SR05" . "SP-25/SR-05")
	    ("SP25-SR30" . "SP-25/SR-30")
	    ("SP27-SR30" . "SP-27/SR-30")
	    ("SP28-SR30" . "SP-28/SR-30")
	    ("SP30-SR30" . "SP-30/SR-30")
	    ("SP31-SR30" . "SP-31/SR-30")
	    ("SP-46 Plaqueta" . "SP-46 PLAQUETA")
	    ("SP46A-SR30" . "SP-46A/SR-30")
	    ("SP-46N" . "SP-46")
	    ("SP46-SR30" . "SP-46/SR-30")
	    ("SP46-SR30N" . "SP-46/SR-30")
	    ("SP47A-SR30" . "SP-47A/SR-30")
	    ("SP-47N" . "SP-47")
	    ("SP47-SR30" . "SP-47/SR-30")
	    ("SP47-SR30N" . "SP-47/SR-30")
	    ("SP48-SR30" . "SP-48/SR-30")
	    ("SP48-SR30N" . "SP-48/SR-30")
	    ("SP59A-SP25" . "SP-59A/SP-25")
	    ("SP59A-SP46A" . "SP-59A/SP46A")
	    ("SP-59N" . "SP-59")
	    ("SP59-SR30" . "SP-59/SR-30")
	    ("SP67-SR30" . "SP-67/SR-30")
	    ("SPB-46N" . "SPB-46")
	    ("SPB-47N" . "SPB-47")
	    ("SR-02N" . "SR-02")
	    ("SR-28 Plaqueta" . "SR-28 PLAQUETA")
	    ("SR-28 Plaqueta1" . "SR-28 PLAQUETA")
	    ("SR-28 Plaqueta2" . "SR-28 PLAQUETA")
	    ("SR-28 Plaqueta3" . "SR-28 PLAQUETA")
	    ("SR-28 Plaqueta4" . "SR-28 PLAQUETA")
	    ("SR-28 Plaqueta5" . "SR-28 PLAQUETA")
	    ("SR-28 PlaquetaN" . "SR-28 PLAQUETA")
	    ("SR-28 PlaquetaN13" . "SR-28 PLAQUETA")
	    ("SR-28 PlaquetaN2" . "SR-28 PLAQUETA")
	    ("SR-28 PlaquetaN20" . "SR-28 PLAQUETA")
	    ("SR-28 PlaquetaN3" . "SR-28 PLAQUETA")
	    ("SR-28 PlaquetaN4" . "SR-28 PLAQUETA")
	    ("SR-28 PlaquetaN5" . "SR-28 PLAQUETA")
	    ("SR-28 PlaquetaN9" . "SR-28 PLAQUETA")
	    ("SR-28N Plaqueta" . "SR-28 PLAQUETA")
	    ("SR-34 Plaqueta" . "SR-34 PLAQUETA")
	    ("SR-34N Plaqueta" . "SR-34 PLAQUETA")
	    ("SR-40 Plaqueta" . "SR-40 PLAQUETA")
	    ("SR-42 Plaqueta" . "SR-42 PLAQUETA")
	    ("SR-42 Plaqueta1" . "SR-42 PLAQUETA")
	    ("SR-42 PlaquetaN" . "SR-42 PLAQUETA")
	    ("SRB01-SRC01" . "SRB-01/SRC-01")
	    ("SRB01-SRC03" . "SRB-01/SRC-03")
	    ("SRB-02N" . "SRB-02")
	    ("SRB-23" . "SRB-23")
	    ("SRC01-SRC03" . "SRC-01/SRC-03")))
  
  
  (if (and (princ "\nSignal blocks required, ")
	   (setq s (ssget '((0 . "INSERT"))))
	   (setq *aoa-c* (1- (cond ((getint (strcat "\nSet initial number <" (itoa (1+ *aoa-c*)) ">: "))) ((1+ *aoa-c*)))))
	   )
    
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i)))
	    o (getpropertyvalue e "BlockTableRecord/Name") 					; old name
	    n (cond ((cdr (assoc o l))) (o)))							; new name

      (ade_odaddrecord e "SDM_SEN_SENALIZACION")
      (ade_odsetfield  e "SDM_SEN_SENALIZACION" "TIPO_SENAL" 0 n)  				; new name
      (ade_odsetfield  e "SDM_SEN_SENALIZACION" "INTERNO_SENAL" 0 (setq *aoa-c* (1+ *aoa-c*)))  ; counter to OD
      (vl-catch-all-apply 'setpropertyvalue (list e "INTERNO" (itoa *aoa-c*)))))		; counter to Att

  (princ)
  )

 

Message 4 of 8

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:
....
	    ("SI08-Plaqueta-SI08Palqueta" . "SI-08 PLAQUETA/ SI-08 PLAQUETA")
	    ("SI08-Plaqueta-SI08PlaquetaN" . "SI-08 PLAQUETA/ SI-08 PLAQUETA")  ; typo??
....

[I think the typo?? question should be one line earlier -- Palqueta instead of Plaqueta as everywhere else.]

Kent Cooper, AIA
Message 5 of 8

BriamR
Advocate
Advocate
Thanks for the answer, the two lines are valid in one case is the name of the block in version 0 and the other is the name of the block in version 1, the name error is to keep a history of your drawing.
0 Likes
Message 6 of 8

BriamR
Advocate
Advocate
Yes, you are right, there are some lines of duplicated data, I had not noticed it, it must be because I am increasing the data in the list, thanks for your answer, I comment, the execution speed improves a lot only remains to say that the lisp that you propose me apparently does not add the consecutive number to the field INTERNO_SENAL of the object data but if in the INTERNO field of the block as did the lisp that I published initially. I leave in the publication an example .dwg file.
0 Likes
Message 7 of 8

ВeekeeCZ
Consultant
Consultant

Ok, code updated. Also, I think the code is simple enough that even you should get oriented within the code.

Message 8 of 8

BriamR
Advocate
Advocate
Thanks for the help, it will be very useful for future projects in my work.
0 Likes