.NET

Reply
Distinguished Contributor
dolives
Posts: 207
Registered: ‎09-04-2002
Message 1 of 7 (198 Views)

list dot paired to form

198 Views, 6 Replies
04-18-2012 07:45 AM

Hi,

I try to make a form with à list dot paired:

(("mscorlib.dll" . "2.0.0.0") ("AcdbMgd.dll" . "18.0.0.0"))

 

A simple form with 2 column and a windows not fix, expandable !

 

My problem how to transfert list to .net (VB) ?

 

Daniel OLIVES

(Sorry for my poor english a french user !)

*Expert Elite*
_gile
Posts: 2,114
Registered: ‎04-29-2006
Message 2 of 7 (189 Views)

Re : list dot paired to form

04-18-2012 08:33 AM in reply to: dolives

Salut,

 

Comment to code obtient-il cette liste, depuis un LISP ?

How do your code get this list, from a LISP ?

Gilles Chanteau
*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 3 of 7 (186 Views)

Re: list dot paired to form

04-18-2012 08:36 AM in reply to: dolives

Have you tried Dictionary(of string,string) or something else

Try this out

  Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim ed As Editor = doc.Editor
            Dim dict As Dictionary(Of String, String) = New Dictionary(Of String, String)
            dict.Add("mscorlib.dll", "2.0.0.0")
            dict.Add("AcdbMgd.dll", "18.0.0.0")
            For Each key As String In dict.Keys
                ed.WriteMessage(vbLf + "{0}" + vbTab + "{1}", key, dict(key))
            Next

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
*Expert Elite*
arcticad
Posts: 1,285
Registered: ‎06-21-2004
Message 4 of 7 (182 Views)

Re: list dot paired to form

04-18-2012 08:50 AM in reply to: Hallex

http://www.dotnetperls.com/keyvaluepair-vbnet

---------------------------



(defun botsbuildbots() (botsbuildbots))
Distinguished Contributor
dolives
Posts: 207
Registered: ‎09-04-2002
Message 5 of 7 (163 Views)

Re: list dot paired to form

04-19-2012 09:19 AM in reply to: dolives

Hi,

Thank you very much !

Daniel OLIVES

Distinguished Contributor
dolives
Posts: 207
Registered: ‎09-04-2002
Message 6 of 7 (162 Views)

Re : list dot paired to form

04-19-2012 09:24 AM in reply to: _gile

Hi Gile,

Yes the list is create form lisp code, i try to just put it in a form i, dot net !

 

daniel OLIVES

*Expert Elite*
_gile
Posts: 2,114
Registered: ‎04-29-2006
Message 7 of 7 (152 Views)

Re : list dot paired to form

04-19-2012 11:39 AM in reply to: dolives

If I don't misunderstand, you build a LispFunction which an argument is dotted pair list, for example:

 

(foo '(("mscorlib.dll" . "2.0.0.0") ("AcdbMgd.dll" . "18.0.0.0")))

 

Your NET code will get the argument as a ResultBuffer (a collection of TypedValues). For the upper example the ResultBuffer will contain these TypedValues where the first item (TypeCode) is a value of the LispDataType enum.

 

For example, this LispFunction Method:


        [LispFunction("foo")]
        public TypedValue foo(ResultBuffer resbuf)
        {
            Editor ed = AcAp.DocumentManager.MdiActiveDocument.Editor;
            if (resbuf == null)
                return new TypedValue((short)LispDataType.Nil);
            else
            {
                foreach (TypedValue tv in resbuf)
                {
                    ed.WriteMessage("{0} : {1}\n", tv.TypeCode, tv.Value);
                }
                return new TypedValue((short)LispDataType.T_atom);
            }
        }

with (foo '(("mscorlib.dll" . "2.0.0.0") ("AcdbMgd.dll" . "18.0.0.0"))) will write on command line:

 

5016 : -1
5016 : -1
5005 : mscorlib.dll
5005 : 2.0.0.0
5018 : -1
5016 : -1
5005 : AcdbMgd.dll
5005 : 18.0.0.0
5018 : -1
5017 : -1

 

5016 => LispDataType.ListBegin

5005 => LispDataType.Text

5018 => LispDataType.DottedPair

5017 => LispDataTypeListEnd

 

Care, if your dotted pairs have a key/value corresponding to valid TypedValues (DxfCode and a corresponding value) it will be seen by .NET as a single TypedValue.

 

(foo '((0 . "INSERT") (10 0.0 0.0 0.0) (66 . 1)))

 

will print:

 

5016 : -1
0 : INSERT
10 : (0,0,0)
66 : 1
5017 : -1

 

I expect it helps. Feel free to post on a French speaking forum we both de more comfortable.

Gilles Chanteau
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!