Insert block with attributes using DCL

amrivasU38U2
Participant
Participant

Insert block with attributes using DCL

amrivasU38U2
Participant
Participant

Can anyone help me create a lisp code based on this dcl. I want to insert a block with attributes. Expected results are in Cable Test.dwg. A big thanks to anyone.

 
 
 
 
 
 
 
 
 
 
0 Likes
Reply
Accepted solutions (2)
1,301 Views
26 Replies
Replies (26)

paullimapa
Mentor
Mentor

Questions:

1. Why do you have a dcl file but not the lsp file?

2. Was the original author BD for CCC NNRDO


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes

amrivasU38U2
Participant
Participant
1. The dcl and lisp are from this forum https://www.cadtutor.net/forum/topic/12525-dcl-radio-buttons/ but i can't proceed with modification of the lisp to work with what expected output i want.
2. I think yes.
0 Likes

paullimapa
Mentor
Mentor

Actually I didn't find in the link you provided the matching dcl code.

But I have even more questions:

1. Since there are only 3 Manufacturers, how many Connector Length options are there to choose from in the popup list? (3FT, 4FT, 5FT, 6FT)

paullimapa_0-1730177063346.png

2. I assume the different Connector Lengths would mean different model #s. How are these determined especially for C2G?

paullimapa_1-1730177182393.png

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes

amrivasU38U2
Participant
Participant
I have already modified the dcl code that I get from the forum. Cable length is 3ft, 6ft, 10ft, 12ft, 15ft, 20ft, 24ft and 25ft. For now, manufacturer is 3 but in I will add maybe whenever possible.
0 Likes

paullimapa
Mentor
Mentor

@amrivasU38U2 code attached with dcl included in lsp function so no need to have a separate dcl file.

Try attach hdmi.lsp

I took an educated guess on the model #s for LIBERTY & EXTRON based on length.

But I have no idea what that would be for C2G but only have the info for 3FT.

This is the section of the code that deals with model #s after the block has been inserted:

 

            (cond
              ((eq *hdmi-manu* "LIBERTY")
               (if (< num 9) ; chk if single digit
                 (setq num "HDPMM0") ; then add 0 to model
                 (setq num "HDPMM") ; else just use model
               )
               (setpropertyvalue (entlast) att-model (strcat num (substr *hdmi-model* 1 (1- (strlen *hdmi-model*))))) ; drop last letter 
              )
              ((eq *hdmi-manu* "EXTRON")
               (if (< num 9) ; chk if single digit
                 (setq num (strcat "0" (itoa num))) ; then add 0 in front and convert to string
                 (setq num (itoa num)) ; else just convert to string
               )
               (setpropertyvalue (entlast) att-model (strcat "26-663-" num))
              )
              ((eq *hdmi-manu* "C2G")
               (setpropertyvalue (entlast) att-model "56782") ; only have this model
              )
            ) ; cond

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes

amrivasU38U2
Participant
Participant
Hi Paullimapa i tested the code and it works however is there a way to output it in this way.

Selecting manufacturer for example LIBERTY and then selecting cable length 3FT it will insert a block _AVSF-PRT CBL-LBL that filled its attributes

DESCRIPTION: 3FT HDMI M TO M
MANUFACTURER: LIBERTY
MODEL: HDPMM03F

In this way i can possibly tweak the code and add other Manufacturer and cable length.

C2G details are:
15ft 50612
12ft 50611
10ft 56784
6ft 56783
3ft 56782

Thank you so much. I appreciate all the efforts.
0 Likes

Sea-Haven
Mentor
Mentor

Another this uses radio buttons of 2 columns choosing values. It uses the library function Multi Radio buttons 2 col. SO its only a few lines of code as the main code is demand loaded. Just save in a support path or add full path to (Load.

 

 

(if (not ah:buttscol)(load "Multi Radio buttons 2col.lsp"))
(if (= ah:but nil)(setq ah:but 1))
(if (= ah:but2 nil)(setq ah:but2 1))
(setq lst1 (list "Select Manufacturer" "LIBERTY" "EXTRON" "C2G" ))
(setq lst2 (list "Select length " "3" "6" "10" "12" "15" "20" "24"))
(ah:buttscol ah:but ah:but2 "HDMI connectors" lst1 lst2)
(setq ans1 (nth ah:2col lst1))
(setq ans2 (atof (nth ah:2col2 lst2)))

 

 

 

0 Likes

paullimapa
Mentor
Mentor

So are you saying that not all manufacturers have the same cable length options?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes

amrivasU38U2
Participant
Participant
Yes, every manufacturer has same set of cable length.
0 Likes

amrivasU38U2
Participant
Participant
Sorry but can you please guide me how can i possibly run this code so i can test how it works.
0 Likes

paullimapa
Mentor
Mentor

One of your posts states

Cable length is 3ft, 6ft, 10ft, 12ft, 15ft, 20ft, 24ft and 25ft.”

But for C2G details are:
15ft 50612
12ft 50611
10ft 56784
6ft 56783
3ft 56782

What happened to :

20ft, 24ft and 25ft.

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes

amrivasU38U2
Participant
Participant
For C2G there is no available 20ft, 24ft, and 25ft. For EXTRON, there is no available 10ft,20ft,24ft and 25ft. For LIBERTY there is no available 12ft and 25ft.
0 Likes

Sea-Haven
Mentor
Mentor

Question 1 to see how it works. 

use appload and load "Multi radio buttons 2 col.

Copy lines 1-6 and paste to command line. You should see the dcl open pick left and right.

Copy lines 7-8 and paste to command line you have the two values.

You would normally include all the code in your code and no need to appload as this is handled by the (load "Multi....)

 

Question 2 if some lengths are not available then you can use this Multi Radio Buttons.lsp You would use the lst1 and choose a supplier, you then run it again with lst2 but that matches what sizes are available from that manufacturer much easier than greying out sizes.

SeaHaven_0-1730248265842.png

Check manufacturer and use correct sizes available next.

SeaHaven_1-1730248321956.png

For code need sizes for each manufacturer.

 

 

0 Likes

amrivasU38U2
Participant
Participant
I tried but encountered an error. The dialog box did not show-up.
0 Likes

amrivasU38U2
Participant
Participant

@paullimapa I added the Cable length per manufacturer but only 3ft for all manufacturer works. Other cable length has an error "Error: bad argument type: consp nil".  Can you please check the attach lisp code.

 
 
 
0 Likes

paullimapa
Mentor
Mentor
Accepted solution

Check out the attached revised Hdmi6.lsp

It gets complicated because not all manufacturers have the same lengths and the # of lengths offered also differ.

But review the lengths where I setup a separate subfunction to make sure they are all there:

 

;;; do_manu_select 
 (defun do_manu_select (itm)
  (cond
   ((eq itm "LIBERTY") 
    (setq L2 '("3FT" "6FT" "10FT" "15FT" "20FT" "24FT"))
   )
   ((eq itm "EXTRON") 
    (setq L2 '("3FT" "6FT" "9FT" "12FT" "15FT"))
   )
   ((eq itm "C2G") 
    (setq L2 '("3FT" "6FT" "10FT" "12FT" "15FT"))
   )
  )   
 )

 

I also added the handling of the different lengths for C2G here:

 

              ((eq *hdmi-manu* "C2G")
               (cond 
                ((eq *hdmi-model* "3FT")
                 (setpropertyvalue (entlast) att-model "56782") 
                )
                ((eq *hdmi-model* "6FT")
                 (setpropertyvalue (entlast) att-model "56783") 
                )
                ((eq *hdmi-model* "10FT")
                 (setpropertyvalue (entlast) att-model "56784") 
                )
                ((eq *hdmi-model* "12FT")
                 (setpropertyvalue (entlast) att-model "50611") 
                )
                ((eq *hdmi-model* "15FT")
                 (setpropertyvalue (entlast) att-model "50612") 
                )
               )
              )

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes

amrivasU38U2
Participant
Participant
Tested already and it's perfectly work. Thank you so much.
If ever, is it possible to make EXTRON and LIBERTY works similar to C2G so can make similar lisp code for other connectors like DP and USB.
0 Likes

Sea-Haven
Mentor
Mentor

I stole from @paullimapa some code, give this a try.

 

 

(defun c:test ( / itm len l2)
(if (not AH:Butts)(load "Multi radio buttons.lsp")) ; loads the program if not loaded already
(if (= but nil)(setq but 1)) 						; this is needed to set default button
(setq itm (ah:butts but "V"   '("Choose Manufacturer" "LIBERTY" "EXTRON" "C2G" )))
(cond
   ((eq itm "LIBERTY") 
    (setq L2 '("Choose length" "3FT" "6FT" "10FT" "15FT" "20FT" "24FT"))
   )
   ((eq itm "EXTRON") 
    (setq L2 '("Choose length" "3FT" "6FT" "9FT" "12FT" "15FT"))
   )
   ((eq itm "C2G") 
    (setq L2 '("Choose length" "3FT" "6FT" "10FT" "12FT" "15FT"))
   )
)
(setq but 1)
(setq len (atof (ah:butts but "V" l2)))
(alert (strcat itm " with length " (rtos len 2 2)))
(princ)
)
(c:test)

 

 It should be obvious how to add more.

 

0 Likes

paullimapa
Mentor
Mentor

You can definitely add more manufacturers

But I’m not sure what you mean by making EXTRON and LIBERTY works similar to C2G. Could you provide example?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes