Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Please help with list construction

7 REPLIES 7
Reply
Message 1 of 8
mid-awe
365 Views, 7 Replies

Please help with list construction

Hi all,

 

I have been working with this and now I get ; error: bad DXF group:

 

(PROGN (IF (SETQ IDX (dict-get "REVISION" "TOTAL"))
	 (PROGN	(REPEAT	IDX
		  (SETQ	REVS   (LIST (STRCAT "REVISION" (ITOA IDX))
				     (CONS "WHO" (dict-get (STRCAT "REVISION" (ITOA IDX)) "WHO"))
				     (CONS "WHEN" (dict-get (STRCAT "REVISION" (ITOA IDX)) "WHEN"))
				     (CONS "WHAT" (dict-get (STRCAT "REVISION" (ITOA IDX)) "WHAT"))
			       )
			REVLST (CONS REVS REVLST)
			IDX    (1- IDX)
		  )
		)
	 )
       )
       (DICT-PUT "REVISIONS" "LIST" REVLST)
)

 I'm not actually attempting any DXF so far as I know. I just need to assemble the list to store in the dictionary for later.

 

This version gives me good results, but, it does not provide the extra distinction of who, when, & what.

 

(PROGN (IF (SETQ IDX (dict-get "REVISION" "TOTAL"))
	 (PROGN	(REPEAT	IDX
		  (SETQ	REVS   (LIST (STRCAT "REVISION" (ITOA IDX))
				     (dict-get (STRCAT "REVISION" (ITOA IDX)) "WHO")
				     (dict-get (STRCAT "REVISION" (ITOA IDX)) "WHEN")
				     (dict-get (STRCAT "REVISION" (ITOA IDX)) "WHAT")
			       )
			REVLST (CONS REVS REVLST)
			IDX    (1- IDX)
		  )
		)
	 )
       )
       (DICT-PUT "REVISIONS" "LIST" REVLST)
)

The expected output is a string formatted as: ("REVISION1" ("WHO" . "NAME") ("WHEN" . "DATE") ("WHAT" . "A SENTENCE ABOUT CHANGES."))

 

ps- I tried mapcar and lambda but finally gave up and tried this approach. This is as close as I've gotten to my goal.

 

Please help. Thank you in advance. 

7 REPLIES 7
Message 2 of 8
aqdam1978
in reply to: mid-awe

Hi,

 

Can you please describe "dict-get"?

Does it something like:

(vlax-ldata-get dict key [default-data [private]])

 ?

Thanks,

Message 3 of 8
mid-awe
in reply to: aqdam1978

Sure, "dict-get" is the same as vlax-ldata-get.

 

Smiley Happy Ha, you answered it before I could reply.

Message 4 of 8
mid-awe
in reply to: mid-awe

@ aqdam1978

 

Ok, so everything works as I need with "vlax-ldata-put" & fails with "dict-put". So, there must be more differences than I am aware of. 

 

I suppose that it is time to switch. Thanks for the help. It was your question that caused me to give it a look. Smiley Happy

Message 5 of 8
hmsilva
in reply to: mid-awe

Hi mid-awe,

 

your first atempt should returns (I don't have AutoCAD to test) a list as you expect, like this

("REVISION1" ("WHO" . "NAME") ("WHEN" . "DATE") ("WHAT" . "A SENTENCE ABOUT CHANGES."))

your first atempt should returns a list like this ("REVISION1" "NAME" "DATE" "A SENTENCE ABOUT CHANGES")

and you say that tou can you put that information in the dictionary, without problem...

For testing purposes, try

 

(PROGN (IF (SETQ IDX (dict-get "REVISION" "TOTAL"))
	 (PROGN	(REPEAT	IDX
		  (SETQ	REVS   (LIST (cons "REVISION" (ITOA IDX))
				     (CONS "WHO" (dict-get (STRCAT "REVISION" (ITOA IDX)) "WHO"))
				     (CONS "WHEN" (dict-get (STRCAT "REVISION" (ITOA IDX)) "WHEN"))
				     (CONS "WHAT" (dict-get (STRCAT "REVISION" (ITOA IDX)) "WHAT"))
			       )
			REVLST (CONS REVS REVLST)
			IDX    (1- IDX)
		  )
		)
	 )
       )
       (DICT-PUT "REVISIONS" "LIST" REVLST)
)

 

Do you get any error?

 

EDIT: too slow Smiley Embarassed

 

Henrique

EESignature

Message 6 of 8
mid-awe
in reply to: hmsilva

Thank you Henrique.

When I try that I get:

; error: bad DXF group: ("REVISION" . "1")
Message 7 of 8
hmsilva
in reply to: mid-awe


@mid-awe wrote:
...
When I try that I get:

; error: bad DXF group: ("REVISION" . "1")

with "vlax-ldata-put"?

EESignature

Message 8 of 8
mid-awe
in reply to: hmsilva

Everything works with "vlax-ldata-put". I compare the output from both functions and I suspect, if I did: (dict-put "revisions" "list" 'revlist), then it would work. I'm not at my desk right now, but I'll give it a test in the morning.

 

Thanks again.

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

Post to forums  

Autodesk Design & Make Report

”Boost