Re: [Tutor] How to create array of variants?

2008-09-12 Thread Krasyn
Alan Gauld wrote: Krasyn [EMAIL PROTECTED] wrote I'm trying to translate the following VB code into Python and not sure how to create an array of variants. All variables in Python are effectively variants - variables that can store any type. So an array of variants equates to a

Re: [Tutor] How to create array of variants?

2008-09-12 Thread Alan Gauld
Krasyn [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] # -*- coding:UTF-8 -*- from comtypes.client import * from array import array Any reason why you are using array here? Why not just a Python list? acad = GetActiveObject(AutoCAD.Application) dwg = acad.ActiveDocument mspace =

Re: [Tutor] How to create array of variants?

2008-09-11 Thread Krasyn
Kelie-2 wrote: Hello group, I'm trying to translate the following VB code into Python and not sure how to create an array of variants. Thanks for your help! VB Code: Sub SetXdata() Dim lineObj As AcadLine Set lineObj = ThisDrawing.ModelSpace.Item(0) Dim

Re: [Tutor] How to create array of variants?

2008-09-11 Thread Alan Gauld
Krasyn [EMAIL PROTECTED] wrote I'm trying to translate the following VB code into Python and not sure how to create an array of variants. All variables in Python are effectively variants - variables that can store any type. So an array of variants equates to a Python list VB Code: Sub

Re: [Tutor] How to create array of variants?

2008-07-08 Thread Kelie
John, Thanks for your reply. I'm aware of list, tuple, sets, etc. and have tried them, which results in an error: Invalid argument type in SetXData method. My understanding is that I do need an array here. Just don't know the correct way of doing it.

Re: [Tutor] How to create array of variants?

2008-07-08 Thread Andre Engels
On Tue, Jul 8, 2008 at 11:00 AM, Kelie [EMAIL PROTECTED] wrote: John, Thanks for your reply. I'm aware of list, tuple, sets, etc. and have tried them, which results in an error: Invalid argument type in SetXData method. My understanding is that I do need an array here. Just don't know the

Re: [Tutor] How to create array of variants?

2008-07-08 Thread Monika Jisswel
Comment : I never did any VB so I am not sure if I understand you. supposing your data comes like this : python code : Data = ( ('A', 1), ('B', 2), ('C', 3), ('D', 4) ) #you can create a list of the items like this : List_Letters = [ x[0] for x in Data] List_Numbers = [ x[1] for x in Data]

Re: [Tutor] How to create array of variants?

2008-07-08 Thread Kelie
Andre Engels andreengels at gmail.com writes: So what does the code of line.SetXData(dataType, dataValue) look like? From that code you should be able to discern what argument type is wanted. Thanks Andre. I don't know how the correct code should look like in Python. In VB, I've posted the

Re: [Tutor] How to create array of variants?

2008-07-08 Thread Alan Gauld
Kelie [EMAIL PROTECTED] wrote I'm trying to translate the following VB code into Python and not sure how to create an array of variants. An array of variants in Python is a list. But I'm not sure why you think you need one? VB Code: Sub SetXdata() Dim lineObj As AcadLine Set lineObj

Re: [Tutor] How to create array of variants?

2008-07-08 Thread Kelie
Alan Gauld alan.gauld at btinternet.com writes: So if you pass in two Python lists containing: DataType = [1001,1070] Data = [Test_Application, 600] Does it work? If not what error do you get? (The full text please) Thanks Alan. This is the error I got: Traceback (most recent call

Re: [Tutor] How to create array of variants?

2008-07-08 Thread John Fouhy
On 09/07/2008, Kelie [EMAIL PROTECTED] wrote: I think comtypes or pywin32 do take care of some conversion between Python types and VB types. But they don't work with AutoCAD. Hi Kelie, This is a short excerpt from _Python Programming on Win32_: In many cases, PythonCOM can translate between

[Tutor] How to create array of variants?

2008-07-07 Thread Kelie
Hello group, I'm trying to translate the following VB code into Python and not sure how to create an array of variants. Thanks for your help! VB Code: Sub SetXdata() Dim lineObj As AcadLine Set lineObj = ThisDrawing.ModelSpace.Item(0) Dim DataType(0 To 1) As Integer Dim

Re: [Tutor] How to create array of variants?

2008-07-07 Thread John Fouhy
On 08/07/2008, Kelie [EMAIL PROTECTED] wrote: I'm trying to translate the following VB code into Python and not sure how to create an array of variants. I'm not sure what an array of variants in VB is -- perhaps an array that can contain objects of any type? Python code import array You