mviewports adskunsupp2004.arx

mviewports adskunsupp2004.arx

Anonymous
Not applicable
708 Views
15 Replies
Message 1 of 16

mviewports adskunsupp2004.arx

Anonymous
Not applicable
is this a file that exists, and does anyone know where i can download it?

i'd like to create an application that shows the frozen/thawed layers in paperspace viewport states for each layer in given mviewports and then be able to freeze and thaw layers in the same.

the difference being you wouldn't need to click in each viewport and set them with vplayer command or layer command.

is this possible with 2004?

thanks for any ideas

thanks
0 Likes
709 Views
15 Replies
Replies (15)
Message 2 of 16

Anonymous
Not applicable
I'd think you could do this without that arx
the list of layer names is in xdata on the vport object

wrote in message news:6029809@discussion.autodesk.com...
is this a file that exists, and does anyone know where i can download it?

i'd like to create an application that shows the frozen/thawed layers in
paperspace viewport states for each layer in given mviewports and then be
able to freeze and thaw layers in the same.

the difference being you wouldn't need to click in each viewport and set
them with vplayer command or layer command.

is this possible with 2004?

thanks for any ideas

thanks
0 Likes
Message 3 of 16

Anonymous
Not applicable
i actually researched this, but don't know if the format has changed for 2004... methods include capturing existing settings of a viewport and redrawing it and various 3rd party (undependable) .arx. do you have any examples for this?
0 Likes
Message 4 of 16

Anonymous
Not applicable
wrote in message news:6029822@discussion.autodesk.com...
i actually researched this, but don't know if the format has changed for
2004... methods include capturing existing settings of a viewport and
redrawing it and various 3rd party (undependable) .arx. do you have any
examples for this?

Sub testvplayer()
On Error GoTo testvplayer_Error
Dim bSuccess As Boolean
Dim ovp As AcadPViewport, oent As AcadEntity, vp, vList As Variant
ThisDrawing.Utility.GetEntity oent, vp, "Pick vport"
Dim i As Long

If TypeOf oent Is AcadPViewport Then
Set ovp = oent
vList = VpLayerList(oent)
For i = LBound(vList) To UBound(vList)
Debug.Print vList(i)
Next
End If
ExitHere:
On Error GoTo 0
Exit Sub

testvplayer_Error:
' LogError ProcName
Resume ExitHere

End Sub

Function VpLayerList(ovp As AcadPViewport) As Variant
On Error GoTo VpLayerList_Error

Dim bSuccess As Boolean
Dim XdataType As Variant
Dim XdataValue As Variant
Dim i As Long
Dim vRtn As Variant
ReDim alist(0) As String

' Get the Xdata from the Viewport
ovp.GetXData "ACAD", XdataType, XdataValue
For i = LBound(XdataType) To UBound(XdataType)
' Look for frozen Layers in this viewport
If XdataType(i) = 1003 Then
alist(UBound(alist)) = XdataValue(i)
ReDim Preserve alist(UBound(alist) + 1)
End If
Next
If UBound(alist) > 0 Then
ReDim Preserve alist(UBound(alist) - 1)
End If

VpLayerList = alist
ExitHere:
On Error GoTo 0
Exit Function

VpLayerList_Error:
'LogError ProcName
Resume ExitHere

End Function

hth
mark
0 Likes
Message 5 of 16

Anonymous
Not applicable
thanks mark,

but how would you go about freezing and then thawing say layer 0 in a given viewport?
0 Likes
Message 6 of 16

Anonymous
Not applicable
add and delete from that xdata list
slipping your names in in between the brackets of the section that holds
those names
hth
mark

wrote in message news:6029961@discussion.autodesk.com...
thanks mark,

but how would you go about freezing and then thawing say layer 0 in a given
viewport?
0 Likes
Message 7 of 16

Anonymous
Not applicable
thanks mark

i read about people finding that impossible to do, specifically thawing layers within a viewport without using a sendcommand, but i'll give it a try when have a little time. is this something you've tried yourself? or it just seems possible.
0 Likes
Message 8 of 16

Anonymous
Not applicable
This was posted some time back...maybe a long time?
I haven't had occasion to try it but it looks potentially sound in concept.
'
Code for freezing layer(s) in a PaperSpace Viewport (mview)
'frank.zander@contractcaddgroup.com
'Paste this code into the code window of a form.
'Then on the form create a button and from the button call the sub
selectVPobjectsToFreeze.

Option Explicit
'Dim ac As AcadApplication
'Dim ThisDrawing As AcadDocument
'Public Function GetAcad()
' On Error Resume Next
' Set ac = GetObject(, "AutoCAD.Application")
' If Err Then
' Err.Clear
' On Error GoTo 0
' Set ac = CreateObject("AutoCAD.Application")
' ac.Visible = True
' End If
'Set GetAcad = ac
'
'End Function


Sub form_load()
'Set ac = GetAcad
'Set ThisDrawing = ac.ActiveDocument
End Sub

Private Sub cmdSelect_Click()
Me.Hide

selectVPobjectsToFreeze

Unload Me

End Sub



Public Sub selectVPobjectsToFreeze()


Dim objEntity As AcadObject
Dim strLayer As String
Dim PT1 As Variant
Dim newSS As AcadSelectionSet
Dim vLayers() As Variant

On Error GoTo err_selectVPobjectsToFreeze

ThisDrawing.StartUndoMark

If ThisDrawing.ActiveSpace = acModelSpace Then
MsgBox "This program only works with PaperSpace Viewports" & vbCr & _
"Please go to PaperSpace", vbCritical
Exit Sub
End If

ThisDrawing.MSpace = True
Set newSS = ThisDrawing.SelectionSets.Add("Vplayers")
ThisDrawing.Utility.Prompt ("Select Objects layers to freeze in the
viewport:" & vbCr)
newSS.SelectOnScreen
For Each objEntity In newSS
strLayer = objEntity.Layer
VpLayerOff (strLayer)
Next

ViewPortUpdate
newSS.Delete
ThisDrawing.EndUndoMark

Exit Sub

err_selectVPobjectsToFreeze:
MsgBox Err.Description, vbInformation
Err.Clear
ThisDrawing.EndUndoMark
End Sub



Sub ViewPortUpdate()
' Update the viewport...
Dim objPViewport As AcadObject

Set objPViewport = ThisDrawing.ActivePViewport
ThisDrawing.MSpace = False
objPViewport.Display (False)
objPViewport.Display (True)
ThisDrawing.MSpace = True
ThisDrawing.Utility.Prompt ("Done!" & vbCr)
End Sub

Sub VpLayerOff(strLayer As String)
' make the layer non displayable (freeze) in the current Viewport
Dim objEntity As AcadObject
Dim objPViewport As AcadObject
Dim objPViewport2 As AcadObject
Dim XdataType As Variant
Dim XdataValue As Variant
Dim I As Integer
Dim Counter As Integer
Dim PT1 As Variant

' Get the active ViewPort
Set objPViewport = ThisDrawing.ActivePViewport

' Get the Xdata from the Viewport
objPViewport.GetXData "ACAD", XdataType, XdataValue

For I = LBound(XdataType) To UBound(XdataType)
' Look for frozen Layers in this viewport
If XdataType(I) = 1003 Then
' Set the counter AFTER the position of the Layer frozen layer(s)
Counter = I + 1
' If the layer is already in the frozen layers xdata of this viewport
the
' exit this sub program
If XdataValue(I) = strLayer Then Exit Sub
End If
Next

' If no frozen layers exist in this viewport then
' find the Xdata location 1002 and place the frozen layer infront of the "}"
' found at Xdata location 1002
If Counter = 0 Then
For I = LBound(XdataType) To UBound(XdataType)
If XdataType(I) = 1002 Then Counter = I - 1
Next
End If

' set the Xdata for the layer that is beeing frozen
XdataType(Counter) = 1003
XdataValue(Counter) = strLayer

ReDim Preserve XdataType(Counter + 1)
ReDim Preserve XdataValue(Counter + 1)

' put the first "}" back into the xdata array
XdataType(Counter + 1) = 1002
XdataValue(Counter + 1) = "}"

' Keep the xdata Array and add one more to the array
ReDim Preserve XdataType(Counter + 2)
ReDim Preserve XdataValue(Counter + 2)

' put the second "}" back into the xdata array
XdataType(Counter + 2) = 1002
XdataValue(Counter + 2) = "}"

' Reset the Xdata on to the viewport
objPViewport.SetXData XdataType, XdataValue

' notice that at this point NOTHING happens in the viewport to visibly show
' any changes to the viewport.
' flipping to a different layout or turning the Mview Off and On will
display the
' Xdata changes to the viewport.
' See sub ViewPortUpdate for how to update the Viewport.

End Sub

wrote in message news:6030709@discussion.autodesk.com...
thanks mark

i read about people finding that impossible to do, specifically thawing
layers within a viewport without using a sendcommand, but i'll give it a try
when have a little time. is this something you've tried yourself? or it
just seems possible.
0 Likes
Message 9 of 16

Anonymous
Not applicable
"MP" wrote in message
news:6030714@discussion.autodesk.com...
This was posted some time back...maybe a long time?
I haven't had occasion to try it but it looks potentially sound in concept.

just tested it and seems to work nicely
:-)
0 Likes
Message 10 of 16

Anonymous
Not applicable
just noticed you were also talking about thawing....
the posted code of course freezes...
you should be able, using that as a guide, to write a function to thaw a
list of layer names

are you saying that if you remove a name from the list that it doesn't
properly thaw the layer???
mark

wrote in message news:6030709@discussion.autodesk.com...
thanks mark

i read about people finding that impossible to do, specifically thawing
layers within a viewport without using a sendcommand,
0 Likes
Message 11 of 16

Anonymous
Not applicable
thanks! great starting point and i now understand what you mean about thawing being the same as not frozen.
0 Likes
Message 12 of 16

Anonymous
Not applicable
The code for freezing by adding XData works, and works well. However, for some reason, doing the 'opposite' by removing the layers from the XData does *not* work for thawing. The code you posted was part of a series of routines that I, too , snagged off the NG's.

The "thaw" routine that was originally posted with it, does not use the XData method to thaw (because it doesnt work) but does work, but only by deleting, then recreating, the viewport and then freezing the layers in the new viewport.

I personally can't use this method, because our viewports have MTEXT blocks with fields attached (Like from the Sheet Set Manager) Erasing, then recreating the viewports 'hoses' the links. But if you dont use fields, the re-creation method works well.
0 Likes
Message 13 of 16

Anonymous
Not applicable
Thanks for the info

wrote in message news:6031333@discussion.autodesk.com...
The code for freezing by adding XData works, and works well. However, for
some reason, doing the 'opposite' by removing the layers from the XData does
*not* work for thawing. The code you posted was part of a series of routines
that I, too , snagged off the NG's.

The "thaw" routine that was originally posted with it, does not use the
XData method to thaw (because it doesnt work) but does work, but only by
deleting, then recreating, the viewport and then freezing the layers in the
new viewport.

I personally can't use this method, because our viewports have MTEXT blocks
with fields attached (Like from the Sheet Set Manager)

------------
how do you attach an Mtext block (you mean an mtext object???) to a vport?
mark
0 Likes
Message 14 of 16

Anonymous
Not applicable
once we place our views in pspace, we add view name references from the Sheet Set manager. These view name references are blocks, with Mtext and fields inside, that reference the ObjectID of the viewport itself. (Most fields use the ObjectID)

Erasing, then re-creating a viewport creates a totally different viewport, with its own unique ObjectID. The names of the viewports, and any section/elev/detail markers referenced anywhere in other drawings, then come out as nothing but "#########".
0 Likes
Message 15 of 16

Anonymous
Not applicable
wrote in message news:6031336@discussion.autodesk.com...
once we place our views in pspace, we add view name references from the
Sheet Set manager. These view name references are blocks, with Mtext and
fields inside, that reference the ObjectID of the viewport itself. (Most
fields use the ObjectID)

Erasing, then re-creating a viewport creates a totally different viewport,
with its own unique ObjectID. The names of the viewports, and any
section/elev/detail markers referenced anywhere in other drawings, then come
out as nothing but "#########".

ah...haven't used the sheet sets yet
so you can't get the sheet set block from the vport object, then revise the
objectid with the new vport's id eh?
are they really using the objecdid and not the handle? doesn't that change
every time dwg is opened?
0 Likes
Message 16 of 16

Anonymous
Not applicable
thanks for the info rocheey, i wonder if the field links can be recreated while the viewport is being recreated...
0 Likes