PDA

View Full Version : Solved: attatch xref



ccastelein
07-07-2005, 10:32 AM
Ok, you knew i would be back...
well apparently my first routine has got a glitch, so im not done yet...
the problem lies with this statement:

ThisDrawing.PaperSpace.AttachExternalReference(XRpath, "XR-Title", ("0,0,0"), 1, 1, 1, 0, False)

where XRpath = "U:\pathname\drawingname.dwg"

ive tried many variations of parens and quotes none of which work...
anyhelp?
ccastelein:doh:

ccastelein
07-11-2005, 07:34 PM
has my post really stumped people? im at a total loss as to why
the statement wont work...

i was hoping at least someone could point me in the right direction as to
why it wont work rather than solve it for me... the error messages are
quite vague..

ccastelein:help

ccastelein
07-12-2005, 08:09 AM
Ok this is a little closer (i think)
i get an error (5) invalid procedure or argument error message with the following:

Set newXR = ThisDrawing.PaperSpace.AttachExternalReference(XRpath, "XR-Title", "0,0,0", 1, 1, 1, 0, False)

where XRpath = "U:\pathname\drawingname.dwg" and
newXR As AcadExternalReference

am i passing the "0,0,0" wrong or isnt the "attachExternalReference" supported in acad?

ccastelein

Tommy
07-15-2005, 12:45 PM
Hi ccastelein,

the 0,0,0 is wrong. You have to remember that Acad like arrays, so to fix the problem setup a zero based array with 0's in them. For this a "short cut" would be:

Dim InsrtPts(0 to 2) as double
Set newXR = ThisDrawing.PaperSpace.AttachExternalReference(XRpath, "XR-Title", InsrtPts,1, 1, 1, 0, False)

This is kinda taking advantage of VBA because when the variable is dimensioned the default values are 0's :)

Tommy

ccastelein
07-19-2005, 02:33 PM
ok, i have tried your suggestion before as it was given as an example in my vba manual...im getting this:

Invalid procedure call or argument (Error 5)

either "An argument (javascript:hhobj_3.Click()) probably exceeds the range of permitted values"
or
"if an attempt is made to call a procedure (javascript:hhobj_4.Click()) that isn't valid on the current platform"

thats why i was wondering if it wasnt supported...cant beleive ADT6 wouldnt.

ccastelein

ccastelein
07-19-2005, 02:45 PM
ok, i think its solved.

i had put the variable InsrtPts in the PUBLIC and no go.
then i put the Dim statement in the module and no go.

then i decided i would try and put the Dim statement right before
the Set newXR statement in the form and Voila it worked....

now why wouldnt the variable be defined if i put it in the Public statement like all the others? strange.
but putting it right before calling it worked..

thanks tommy
ccastelein:cloud9:

Tommy
07-19-2005, 02:46 PM
The only thing I can say is this worked for me in Acad 2000i :dunno

'for paper space

Sub AA()
Dim newXR As AcadExternalReference
XRpath = "c:\acad\abtit.dwg"
Dim InsrtPts(0 To 2) As Double
Set newXR = ThisDrawing.PaperSpace.AttachExternalReference(XRpath, "XR-Title", InsrtPts, 1, 1, 1, 0, False)
End Sub

'and for model space

Sub AA()
Dim newXR As AcadExternalReference
XRpath = "c:\acad\abtit.dwg"
Dim InsrtPts(0 To 2) As Double
InsrtPts(0) = 15
Set newXR = ThisDrawing.ModelSpace.AttachExternalReference(XRpath, "XR-Title", InsrtPts, 1, 1, 1, 0, False)
End Sub

Tommy
07-19-2005, 02:49 PM
:rotlaugh:Great!

I hate it when it works right after it didn't! :rofl:

I'll be here, so any questions you have I'll be more than happy to help where I can :)

deepti
07-19-2007, 04:16 AM
Hi,

I am completely new to AutoCAD 2002 and the various API available for coding with VB, can u help me how do i go about and also it would be great if there is any documentation which explains about various methods available and their purpose.

Thanks in advance.
Deepti