Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dim As Variant in VFP?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00345401
Message ID:
00345462
Vues:
26
Hey, Roi;

I've been doing some experimenting with this stuff, too. I have been able to assign an ACAD point to an array (returns as Numeric) using:

ACAD = GetObject(,"AutoCAD.Application")
DOC = ACAD.ActiveDocument
inspoint=DOC.Utility.Getpoint(, "Select Point: ")


But, when I try to proceed and insert a block (a file, actually) at that point with:

DOC.ModelSpace.InsertBlock(InsPoint, "G:\CADD\DETAILS\PresFurn.DWG",1,1,0)

I get back the error:
OLE IDispatch exception code 0 from AutoCAD Application:
Invalid argument insPoint in InsertionPoint property


I was assuming it's whining because of the TYPE - because I swear I'm using the exact same variable I got from ACAD in the lines above! Gee - you'd think ACAD would take it back in the same format it gives it out!?!?!?

Can you help me understand this behaviour?

TIA

>Hi Michael,
>
>I just made a quick test and got your code to work. I changed the array subscript references to 1 and 2:
>
>ACAD = GETOBJECT(,"AutoCAD.Application")
>ThisDrawing = ACAD.ActiveDocument
>
>InsPt = ThisDrawing.Utility.GetPoint(, "Select Insertion Point: ")
>strX = InsPt( 1 )
>strY = InsPt( 2 )
>Units = ThisDrawing.GetVariable("luprec")&& ' get the drawing's units precision
>
>?strx
>?stry
>?Units
>
>and it worked without a problem. I'm not sure what FormatPnt does so I can't help you there. luprec is just the current number of decimal places set for the .dwg.
>
>Just a note, the point array has 3 items, xCoord, yCoord, zCoord. If you are inserting blocks you may want to use the zCoord as well. Also you need to check for outside the limits error, if the user is picking a point acad will handle it by itself (it'll keep prompting until they pick a point inside the limits), but if you are just inserting a block you'll need to either check first, or turn the sysvar 'limcheck' off first.
>
>hth
>
>>I'm trying to insert drawings into AutoCAD from VFP. Of course, there are guides for doing this stuff in VB, but not for VFP. Most of my problems are related to variable types that don't seem to be available in VFP.
>>
>>For example, to grab the X,Y,Z co-ordinate of a point in AutoCAD, you must:
>>
>>==================================================================
>>Dim InsPt As Variant
>>Dim strX As String, strY As String
>>Dim Units As Long
>>
>>' Return a point using a prompt
>>InsPt = ThisDrawing.Utility.GetPoint(, "Select Insertion Point: ")
>>strX = InsPt(0)
>>strY = InsPt(1)
>>Units = ThisDrawing.GetVariable("luprec") ' get the drawing's units precision
>>
>>strX = FormatPnt(strX, Units) ' format the point to the drawing's units precision
>>strY = FormatPnt(strY, Units)
>>edXpnt.Text = strX ' display the point
>>edYpnt.Text = strY
>>==================================================================
>>
>>My question is, how do I deal with variables of type 'variant' in VFP?
>>
>>TIA
Kogo Michael Hogan

"Pinky, are you pondering what I'm pondering?"
I think so Brain, but "Snowball for Windows"?

Ideate Web Site
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform