VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

oDwg.PlotConfigurations(strPageSetup) Broken!

10 REPLIES 10
Reply
Message 1 of 11
Anonymous
196 Views, 10 Replies

oDwg.PlotConfigurations(strPageSetup) Broken!

Set oPlotCfg = oDwg.PlotConfigurations(strPageSetup)
This standard method doesn't for return an object in 2005 for me.
(and there's no syntax error)

I have to spin through the plot configurations like this.
For Each oPlotCfg1 In oDwg.PlotConfigurations
If StrComp(oPlotCfg1.Name, "_24x36", vbTextCompare) = 0 Then
Exit For
End If
Next

OK Autodesk, I wasted 30 mins on this one, you can reimburse me $75
to.......
(if this works, I could become rich )

- Ted
10 REPLIES 10
Message 2 of 11
Anonymous
in reply to: Anonymous

are you using variable declarations and option explicit?

Oh come now, everyone knows you don't get rich writing CAD apps....everyone
just assumes it's part of autoCAD 🙂

-Chris

"TedSch" wrote in message
news:4954384@discussion.autodesk.com...
Set oPlotCfg = oDwg.PlotConfigurations(strPageSetup)
This standard method doesn't for return an object in 2005 for me.
(and there's no syntax error)

I have to spin through the plot configurations like this.
For Each oPlotCfg1 In oDwg.PlotConfigurations
If StrComp(oPlotCfg1.Name, "_24x36", vbTextCompare) = 0 Then
Exit For
End If
Next

OK Autodesk, I wasted 30 mins on this one, you can reimburse me $75
to.......
(if this works, I could become rich )

- Ted
Message 3 of 11
Anonymous
in reply to: Anonymous

The editor always puts it in, and I alway declare everything - SOP.

"Don't get rich..." How well I know. I've been doing it since 1983.
About once a year, I get fed up with "this" working different than "that",
and have to say something.

Mounting soap box:

VBA is the most productive and interactive development environment.
IMHO, Autodesk could be more active in filling in VBA. They are
profitable enough to apply some more effort to this. How long will
unsupported.arx be required? How long before I can remove the
sendcommand from my code?

- Ted

"Chris Shoemaker" wrote in message
news:4954411@discussion.autodesk.com...
are you using variable declarations and option explicit?

Oh come now, everyone knows you don't get rich writing CAD apps....everyone
just assumes it's part of autoCAD 🙂

-Chris

"TedSch" wrote in message
news:4954384@discussion.autodesk.com...
Set oPlotCfg = oDwg.PlotConfigurations(strPageSetup)
This standard method doesn't for return an object in 2005 for me.
(and there's no syntax error)

I have to spin through the plot configurations like this.
For Each oPlotCfg1 In oDwg.PlotConfigurations
If StrComp(oPlotCfg1.Name, "_24x36", vbTextCompare) = 0 Then
Exit For
End If
Next

OK Autodesk, I wasted 30 mins on this one, you can reimburse me $75
to.......
(if this works, I could become rich )

- Ted
Message 4 of 11
Anonymous
in reply to: Anonymous

Please forward your $75 to me when you receive it.

Sub Test()
Dim allPCfgs As AcadPlotConfigurations
Dim myPCfg As AcadPlotConfiguration
Set allPCfgs = ThisDrawing.PlotConfigurations
allPCfgs.Add "Test"
Set myPCfg = allPCfgs.Item("Test")
MsgBox "My name is " & myPCfg.Name
End Sub


--
R. Robert Bell


"TedSch" wrote in message
news:4954384@discussion.autodesk.com...
Set oPlotCfg = oDwg.PlotConfigurations(strPageSetup)
This standard method doesn't for return an object in 2005 for me.
(and there's no syntax error)

I have to spin through the plot configurations like this.
For Each oPlotCfg1 In oDwg.PlotConfigurations
If StrComp(oPlotCfg1.Name, "_24x36", vbTextCompare) = 0 Then
Exit For
End If
Next

OK Autodesk, I wasted 30 mins on this one, you can reimburse me $75
to.......
(if this works, I could become rich )

- Ted
Message 5 of 11
Anonymous
in reply to: Anonymous

Your right, I owe you.

I've been making an import system as part of Dwg setup routine.
And, I would like to give the user the option of updating the pagesetups
to the current std. If one of the imported pagesetups is the current one
for a layout, then I would like to update it with the new import.
Unfortunately, I was more hoping to do something like:
Set oDict = ThisDrawing.Dictionaries("ACAD_LAYOUTS")

Then loop through it to see the current plotconfigs but Acad won't let me.
These dicts must be protected. I guess I will use Ed Jobe's lisp/vlax code
to get the info.

Thanks, Ted






"R. Robert Bell" wrote in message
news:4954585@discussion.autodesk.com...
Please forward your $75 to me when you receive it.

Sub Test()
Dim allPCfgs As AcadPlotConfigurations
Dim myPCfg As AcadPlotConfiguration
Set allPCfgs = ThisDrawing.PlotConfigurations
allPCfgs.Add "Test"
Set myPCfg = allPCfgs.Item("Test")
MsgBox "My name is " & myPCfg.Name
End Sub


--
R. Robert Bell


"TedSch" wrote in message
news:4954384@discussion.autodesk.com...
Set oPlotCfg = oDwg.PlotConfigurations(strPageSetup)
This standard method doesn't for return an object in 2005 for me.
(and there's no syntax error)

I have to spin through the plot configurations like this.
For Each oPlotCfg1 In oDwg.PlotConfigurations
If StrComp(oPlotCfg1.Name, "_24x36", vbTextCompare) = 0 Then
Exit For
End If
Next

OK Autodesk, I wasted 30 mins on this one, you can reimburse me $75
to.......
(if this works, I could become rich )

- Ted
Message 6 of 11
Anonymous
in reply to: Anonymous

Exactly what do you want to do? Either I'm not following or you're not
making any sense. The dicts aren't protected and there is no problem
retrieving them. Just take Bob's code one step further:

Sub GetPlotConfigs()
Dim oPltCfg As AcadPlotConfiguration
For Each oPltCfg In ThisDrawing.PlotConfigurations
If oPltCfg.Name Like "_24X36" Then
MsgBox oPltCfg.Name
'you now have the plotconfig object so do whatever
End If
Next
End Sub

Now you can iterate and eventually retrieve the object you're after. It may
have been your use of StrComp instead of just using Like that was throwing
you.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Message 7 of 11
Anonymous
in reply to: Anonymous

>>If one of the imported pagesetups is the current one
for a layout, then I would like to update it with the new import.

It shouldn't matter what the current layout is. Just import all updated
PlotConfigurations. You will get an error if any already exist in the
PlotConfigurations collection due to the fact that a collection is key based
and the index key already exists. Therefore, you can't use the same key over
again. So I just delete all existing PC's and import all updated ones. I
have a dvb on the AUGI Exchange that does all of this, using ObjectDbx to
perform the update from a template without user intervention, making it a
one-click update. There's also, one in there that presents a user with a
dialog where they can choose which ones to update.

--
----
Ed
----
Message 8 of 11
Anonymous
in reply to: Anonymous

Not making sense - I had a condition where the active pagesetup
was modified from one of the same name. "24x36" was active
and the selection list. I was able to change the activer version to a
36x48 sheet, but it left the name the same. So I had a two instances
of 24x26 in the page setup window. When you clicked on one, it
showed 24x36 as page size, the other showed 36x48. I was worried
about updating the active copy of this page setup to a newly imported
version.

Using the dbview app, I could see how the PlotConfig was
copied from ACAD_PLOTSTETTINGS to ACAD_LAYOUT>Layout
in the Named Object Dictionary. So first I was trying to get the name
of the active plotConfig which I ought to be able to dig out of ACAD_LAYOUT
but I couldn't Set to it. The layout object should have an active plotconfig
property.

I was already using similar code to Bob's and yours. Not sure why it broke.
I restarted my computer and that part fixed itself.

Thanks, Ted



"Mike Tuersley" wrote in message
news:4955533@discussion.autodesk.com...
Exactly what do you want to do? Either I'm not following or you're not
making any sense. The dicts aren't protected and there is no problem
retrieving them. Just take Bob's code one step further:

Sub GetPlotConfigs()
Dim oPltCfg As AcadPlotConfiguration
For Each oPltCfg In ThisDrawing.PlotConfigurations
If oPltCfg.Name Like "_24X36" Then
MsgBox oPltCfg.Name
'you now have the plotconfig object so do whatever
End If
Next
End Sub

Now you can iterate and eventually retrieve the object you're after. It may
have been your use of StrComp instead of just using Like that was throwing
you.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Message 9 of 11
Anonymous
in reply to: Anonymous

I restarted Acad several times, but when I restarted my whole system,
most of my problems went away. Should have done that first.

I looked at your code for Augi. I have something very similar working.

It still drives me crazy (ier) that you can't do some thing like:
Thisdrawing.layouts("Layout1").ActivePlotConfig.Name

But that's where your Lisp/Vlax workaround come in.

Thanks,

- Ted

"Ed Jobe" wrote in message
news:4955954@discussion.autodesk.com...
>>If one of the imported pagesetups is the current one
for a layout, then I would like to update it with the new import.

It shouldn't matter what the current layout is. Just import all updated
PlotConfigurations. You will get an error if any already exist in the
PlotConfigurations collection due to the fact that a collection is key based
and the index key already exists. Therefore, you can't use the same key over
again. So I just delete all existing PC's and import all updated ones. I
have a dvb on the AUGI Exchange that does all of this, using ObjectDbx to
perform the update from a template without user intervention, making it a
one-click update. There's also, one in there that presents a user with a
dialog where they can choose which ones to update.

--
----
Ed
----
Message 10 of 11
Anonymous
in reply to: Anonymous

Cool! Sorry I just didn't understand what you were saying 😃

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Message 11 of 11
Anonymous
in reply to: Anonymous

Definitely there are holes in the vba api.

--
----
Ed
----
"TedSch" wrote in message
news:4956378@discussion.autodesk.com...
I restarted Acad several times, but when I restarted my whole system,
most of my problems went away. Should have done that first.

I looked at your code for Augi. I have something very similar working.

It still drives me crazy (ier) that you can't do some thing like:
Thisdrawing.layouts("Layout1").ActivePlotConfig.Name

But that's where your Lisp/Vlax workaround come in.

Thanks,

- Ted

"Ed Jobe" wrote in message
news:4955954@discussion.autodesk.com...
>>If one of the imported pagesetups is the current one
for a layout, then I would like to update it with the new import.

It shouldn't matter what the current layout is. Just import all updated
PlotConfigurations. You will get an error if any already exist in the
PlotConfigurations collection due to the fact that a collection is key based
and the index key already exists. Therefore, you can't use the same key over
again. So I just delete all existing PC's and import all updated ones. I
have a dvb on the AUGI Exchange that does all of this, using ObjectDbx to
perform the update from a template without user intervention, making it a
one-click update. There's also, one in there that presents a user with a
dialog where they can choose which ones to update.

--
----
Ed
----

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

Post to forums  

Autodesk Design & Make Report

”Boost