Concatenate Columns and Add custom header to Cable from/To Report

Concatenate Columns and Add custom header to Cable from/To Report

leonardo.alvarez4SZJL
Advocate Advocate
281 Views
3 Replies
Message 1 of 4

Concatenate Columns and Add custom header to Cable from/To Report

leonardo.alvarez4SZJL
Advocate
Advocate

Hi,

 

I am using AutoCAD Electrical, Windows 10.

 

I'm trying to customize a Report with a User Post File and I am using this link as a good resource.

https://autodesk.typepad.com/systemsdesign/2014/08/customize-a-report-with-a-user-post-file.html

 

However I am not getting the desired output. 

Capture.PNG

I want to be able to combine LOC2 and PIN2. So that LOC2 holds the value and it will look like this.

"LCC L : 1X1"

 

Here is the code I wrote for it but it does not work once I select User Post on the bottom right and select third option.

      (if (= user_3 "1")
        (progn
          (setq rtrn '()) ; Start a new blank list to add 
		  (foreach data wd_rdata ; look at each line in the report
			; pull out the 2 lines
			(setq LOC2 (nth 4 data))
			(setq PIN2 (nth 6 data))
			; string them together adding the space if non-blank
			(if (/= LOC2 "")
				(if (/= PIN2 "") (setq LOC2 (strcat LOC2 "" PIN2)))
				; else
				(setq LOC2 PIN2)
			)
			; Plug this new value back in the LOC2 field using the supplied data
			(setq data (wd_nth_subst 4 LOC2 data))
			; Need to reverse the list since build it by adding on at the..
			(setq rtrn (reverse rtrn))
		  )
		)
	  ) 

 

Can someone help and guide me in the right direction. I also would like to make a custom header as well. I have attached the .lsp and .cdl files.

 

 

0 Likes
282 Views
3 Replies
Replies (3)
Message 2 of 4

leonardo.alvarez4SZJL
Advocate
Advocate

So I was able to solve my issue. I was missing one line of code and also had another line miss placed.

 

Here is the fixed version:

 

      (if (= user_3 "1")
        (progn
          (setq rtrn '()) 				; Start a new blank list to add 
		  (foreach data wd_rdata 		; look at each line in the report
			; pull out the 2 lines
			(setq LOC2 (nth 4 data))
			(setq PIN2 (nth 6 data))
			; string them together adding the space if non-blank
			(if (/= LOC2 "")
				(if (/= PIN2 "") (setq LOC2 (strcat LOC2 "" PIN2)))
				; else
				(setq LOC2 PIN2)
			)
			; Plug this new value back in the LOC2 field using the supplied data
			(setq data (wd_nth_subst 4 LOC2 data))
			; add this line of data into my new list as the first element
			(setq rtrn (cons data rtrn))
		  )
		  ; Need to reverse the list since build it by adding on at the..
		  (setq rtrn (reverse rtrn))

		)
	  ) 

 

Message 3 of 4

ronjonp
Advisor
Advisor

FWIW

;; This
(if (/= loc2 "")
  (if (/= pin2 "")
    (setq loc2 (strcat loc2 "" pin2))
  )
  (setq loc2 pin2)
)

;; Could be this
(setq loc2 (if (/= loc2 pin2 "")
	     (strcat loc2 "" pin2)
	     pin2
	   )
)
Message 4 of 4

ВeekeeCZ
Consultant
Consultant

@ronjonp wrote:

FWIW

;; This
(if (/= loc2 "")
  (if (/= pin2 "")
    (setq loc2 (strcat loc2 "" pin2))
  )
  (setq loc2 pin2)
)

;; Could be this
(setq loc2 (if (/= loc2 pin2 "")
	     (strcat loc2 "" pin2)
	     pin2
	   )
)

 

Not the same result.