Jump to content

Search the Community

Showing results for tags 'vplayeroff'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • CADTutor
    • News, Announcements & FAQ
    • Feedback
  • AutoCAD
    • AutoCAD Beginners' Area
    • AutoCAD 2D Drafting, Object Properties & Interface
    • AutoCAD Drawing Management & Output
    • AutoCAD 3D Modelling & Rendering
    • AutoCAD Vertical Products
    • AutoCAD LT
    • CAD Management
    • AutoCAD Bugs, Error Messages & Quirks
    • AutoCAD General
    • AutoCAD Blogs
  • AutoCAD Customization
    • The CUI, Hatches, Linetypes, Scripts & Macros
    • AutoLISP, Visual LISP & DCL
    • .NET, ObjectARX & VBA
    • Application Beta Testing
    • Application Archive
  • Other Autodesk Products
    • Autodesk 3ds Max
    • Autodesk Revit
    • Autodesk Inventor
    • Autodesk Software General
  • Other CAD Products
    • BricsCAD
    • SketchUp
    • Rhino
    • SolidWorks
    • MicroStation
    • Design Software
    • Catch All
  • Resources
    • Tutorials & Tips'n'Tricks
    • AutoCAD Museum
    • Blocks, Images, Models & Materials
    • Useful Links
  • Community
    • Introduce Yourself
    • Showcase
    • Work In Progress
    • Jobs & Training
    • Chat
    • Competitions

Categories

  • Programs and Scripts
  • 2D AutoCAD Blocks
  • 3D AutoCAD Blocks
  • Images
    • Backgrounds

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Found 1 result

  1. Hi all, Trying to convert the popular VB VPlayerOff function to VB.Net with added functionality of turning a layer off in all viewports in a layout. My code seems to do everything right except update the Xdata with the new results. I tried manipulating the Xdata result buffer initially but is said it was read only so that is why I have done it this way. I will post the Xdata functions from "From Jerry Winters AU 2009 Class - "Store it in the DWG: XData, Extension Dictionaries and Object Data Through .NET" in a separate post since I went over my allotted 15000 charaters. Note, Current code needs an object on a layer called 'test' in drawing file, with something in the layer . Thanks Mike PS - first time posting so hope I did this right! [size=3][font=Times New Roman][color=blue][font=Consolas]Imports[/font][/color][font=Consolas] Autodesk.AutoCAD.Interop[/font][/font][/size] [font=Times New Roman][size=3][color=blue][font=Consolas]Imports[/font][/color][font=Consolas] Autodesk.AutoCAD.Interop.Common[/font][/size] [size=3][color=blue][font=Consolas]Imports[/font][/color][font=Consolas] Autodesk.AutoCAD.Runtime[/font][/size] [size=3][color=blue][font=Consolas]Imports[/font][/color][font=Consolas] Autodesk.AutoCAD[/font][/size] [size=3][color=blue][font=Consolas]Imports[/font][/color][font=Consolas] Autodesk.AutoCAD.DatabaseServices[/font][/size] [size=3][color=blue][font=Consolas]Imports[/font][/color][font=Consolas] Autodesk.AutoCAD.EditorInput[/font][/size] [size=3][color=blue][font=Consolas]Imports[/font][/color][font=Consolas] Autodesk.AutoCAD.Geometry[/font][/size] [size=3][color=blue][font=Consolas]Imports[/font][/color][font=Consolas] Autodesk.AutoCAD.ApplicationServices[/font][/size] [size=3][color=blue][font=Consolas]Imports[/font][/color][font=Consolas] Autodesk.AutoCAD.ApplicationServices.[color=#2b91af]Application[/color][/font][/size] [size=3][color=blue][font=Consolas]Imports[/font][/color][font=Consolas] Autodesk.AutoCAD.LayerManager[/font][/size] [size=3][color=blue][font=Consolas]Imports[/font][/color][font=Consolas] Autodesk.AutoCAD.Windows[/font][/size] [size=3][color=blue][font=Consolas]Public[/font][/color][font=Consolas] [color=blue]Class[/color] [color=#2b91af]vbTools[/color][/font][/size] [size=3][font=Consolas]<[color=#2b91af]CommandMethod[/color]([color=#a31515]"VPLOFF"[/color])> _[/font][/size] [size=3][color=blue][font=Consolas]Public[/font][/color][font=Consolas] [color=blue]Sub[/color] VPLOFF()[/font][/size] [size=3][color=blue][font=Consolas]Dim[/font][/color][font=Consolas] myDB [color=blue]As[/color] [color=#2b91af]Database[/color] = [color=#2b91af]HostApplicationServices[/color].WorkingDatabase[/font][/size] [size=3][color=blue][font=Consolas]Using[/font][/color][font=Consolas] myTrans [color=blue]As[/color] [color=#2b91af]Transaction[/color] = myDB.TransactionManager.StartTransaction[/font][/size] [size=3][color=blue][font=Consolas]Dim[/font][/color][font=Consolas] myBT [color=blue]As[/color] [color=#2b91af]BlockTable[/color] = myDB.BlockTableId.GetObject([color=#2b91af]OpenMode[/color].ForWrite)[/font][/size] [size=3][color=blue][font=Consolas]For[/font][/color][font=Consolas] [color=blue]Each[/color] myBtrID [color=blue]As[/color] [color=#2b91af]ObjectId[/color] [color=blue]In[/color] myBT[/font][/size] [size=3][color=blue][font=Consolas] Dim[/font][/color][font=Consolas] myBTR [color=blue]As[/color] [color=#2b91af]BlockTableRecord[/color] = myBtrID.GetObject([color=#2b91af]OpenMode[/color].ForWrite)[/font][/size] [size=3][color=blue][font=Consolas] If[/font][/color][font=Consolas] myBTR.IsLayout = [color=blue]True[/color] [color=blue]Then[/color][/font][/size] [size=3][color=blue][font=Consolas] Dim[/font][/color][font=Consolas] myLayout [color=blue]As[/color] [color=#2b91af]Layout[/color] = myBTR.LayoutId.GetObject([color=#2b91af]OpenMode[/color].ForWrite)[/font][/size] [size=3][color=blue][font=Consolas] Dim[/font][/color][font=Consolas] myLayoutString [color=blue]As[/color] [color=blue]String[/color] = myLayout.LayoutName[/font][/size] [size=3][color=blue][font=Consolas] Dim[/font][/color][font=Consolas] myVPIDs [color=blue]As[/color] [color=#2b91af]ObjectIdCollection[/color] = myLayout.GetViewports()[/font][/size] [size=3][color=blue][font=Consolas] For[/font][/color][font=Consolas] [color=blue]Each[/color] myVPortID [color=blue]As[/color] [color=#2b91af]ObjectId[/color] [color=blue]In[/color] myVPIDs[/font][/size] [size=3][color=blue][font=Consolas] Dim[/font][/color][font=Consolas] myVP [color=blue]As[/color] [color=#2b91af]Viewport[/color] = [color=blue]DirectCast[/color](myTrans.GetObject(myVPortID, [color=#2b91af]OpenMode[/color].ForWrite), [color=#2b91af]Viewport[/color])[/font][/size] [size=3][font=Consolas] DocumentManager.MdiActiveDocument.Editor.WriteMessage(myVP.Layer + vbNewLine)[/font][/size] [size=3][font=Consolas] VpLayerOff([color=#a31515]"test"[/color], myVPortID)[/font][/size] [size=3][font=Consolas] myVP.UpdateDisplay()[/font][/size] [size=3][color=blue][font=Consolas] Next[/font][/color][/size] [size=3][color=blue][font=Consolas] End[/font][/color][font=Consolas] [color=blue]If[/color][/font][/size] [size=3][color=blue][font=Consolas]Next[/font][/color][/size] [size=3][color=blue][font=Consolas]End[/font][/color][font=Consolas] [color=blue]Using[/color][/font][/size] [size=3][color=blue][font=Consolas]End[/font][/color][font=Consolas] [color=blue]Sub[/color][/font][/size] [size=3][color=blue][font=Consolas]Sub[/font][/color][font=Consolas] VpLayerOff([color=blue]ByVal[/color] myVpLyrName [color=blue]As[/color] [color=blue]String[/color], [color=blue]ByRef[/color] myVPID [color=blue]As[/color] [color=#2b91af]ObjectId[/color])[/font][/size] [size=3][color=blue][font=Consolas]Dim[/font][/color][font=Consolas] I [color=blue]As[/color] [color=blue]Integer[/color][/font][/size] [size=3][color=blue][font=Consolas]Dim[/font][/color][font=Consolas] Counter [color=blue]As[/color] [color=blue]Integer[/color][/font][/size] [size=3][color=blue][font=Consolas]Dim[/font][/color][font=Consolas] myResBuff [color=blue]As[/color] [color=#2b91af]ResultBuffer[/color] = GetXData(myVPID, [color=#a31515]"ACAD"[/color])[/font][/size] [size=3][color=blue][font=Consolas]Dim[/font][/color][font=Consolas] myNewResBuff [color=blue]As[/color] [color=blue]New[/color] [color=#2b91af]ResultBuffer[/color][/font][/size] [size=3][color=blue][font=Consolas]If[/font][/color][font=Consolas] myResBuff [color=blue]Is[/color] [color=blue]Nothing[/color] = [color=blue]False[/color] [color=blue]Then[/color][/font][/size] [size=3][color=blue][font=Consolas]For[/font][/color][font=Consolas] I = LBound(myResBuff.AsArray) [color=blue]To[/color] UBound(myResBuff.AsArray)[/font][/size] [size=3][color=green][font=Consolas] 'debug print out Xdata[/font][/color][/size] [size=3][font=Consolas] DocumentManager.MdiActiveDocument.Editor.WriteMessage(myResBuff.AsArray(I).TypeCode & vbTab & myResBuff.AsArray(I).Value.ToString & vbNewLine)[/font][/size] [size=3][color=blue][font=Consolas] If[/font][/color][font=Consolas] myResBuff.AsArray(I).TypeCode = 1003 [color=blue]Then[/color][/font][/size] [size=3][font=Consolas] Counter = I + 1[/font][/size] [size=3][color=blue][font=Consolas] If[/font][/color][font=Consolas] myResBuff.AsArray(I).Value.ToString = myVpLyrName [color=blue]Then[/color][/font][/size] [size=3][color=blue][font=Consolas] Exit Sub[/font][/color][/size] [size=3][color=blue][font=Consolas] End[/font][/color][font=Consolas] [color=blue]If[/color][/font][/size] [size=3][color=blue][font=Consolas] End[/font][/color][font=Consolas] [color=blue]If[/color][/font][/size] [size=3][color=blue][font=Consolas]Next[/font][/color][/size] [size=3][color=blue][font=Consolas]Else[/font][/color][/size] [size=3][font=Consolas]MsgBox([color=#a31515]"NO XData under that AppName."[/color])[/font][/size] [size=3][color=blue][font=Consolas]End[/font][/color][font=Consolas] [color=blue]If[/color][/font][/size] [size=3][color=blue][font=Consolas]If[/font][/color][font=Consolas] Counter = 0 [color=blue]Then[/color][/font][/size] [size=3][color=blue][font=Consolas]For[/font][/color][font=Consolas] I = LBound(myResBuff.AsArray) [color=blue]To[/color] UBound(myResBuff.AsArray)[/font][/size] [size=3][color=blue][font=Consolas] If[/font][/color][font=Consolas] myResBuff.AsArray(I).TypeCode = 1002 [color=blue]Then[/color][/font][/size] [size=3][font=Consolas] Counter = I - 1[/font][/size] [size=3][color=blue][font=Consolas] End[/font][/color][font=Consolas] [color=blue]If[/color][/font][/size] [size=3][color=blue][font=Consolas]Next[/font][/color][/size] [size=3][color=blue][font=Consolas]End[/font][/color][font=Consolas] [color=blue]If[/color][/font][/size] [size=3][color=green][font=Consolas]'adds existing data to the new result buffer we are creating[/font][/color][/size] [size=3][color=blue][font=Consolas]For[/font][/color][font=Consolas] I = LBound(myResBuff.AsArray) [color=blue]To[/color] Counter - 1[/font][/size] [size=3][font=Consolas]myNewResBuff.Add([color=blue]New[/color] [color=#2b91af]TypedValue[/color](myResBuff.AsArray(I).TypeCode, myResBuff.AsArray(I).Value))[/font][/size] [size=3][color=blue][font=Consolas]Next[/font][/color][/size] [size=3][color=green][font=Consolas]'appends the new frozen layer and closes the set[/font][/color][/size] [size=3][font=Consolas]myNewResBuff.Add([color=blue]New[/color] [color=#2b91af]TypedValue[/color](1003, myVpLyrName))[/font][/size] [size=3][font=Consolas]myNewResBuff.Add([color=blue]New[/color] [color=#2b91af]TypedValue[/color](1002, [color=#a31515]"}"[/color]))[/font][/size] [size=3][font=Consolas]myNewResBuff.Add([color=blue]New[/color] [color=#2b91af]TypedValue[/color](1002, [color=#a31515]"}"[/color]))[/font][/size] [size=3][color=green][font=Consolas]'debug display to see new record buffer[/font][/color][/size] [size=3][font=Consolas]DocumentManager.MdiActiveDocument.Editor.WriteMessage(vbNewLine & vbNewLine)[/font][/size] [size=3][color=blue][font=Consolas]For[/font][/color][font=Consolas] I = LBound(myNewResBuff.AsArray) [color=blue]To[/color] UBound(myNewResBuff.AsArray)[/font][/size] [size=3][color=green][font=Consolas]'debug print out Xdata[/font][/color][/size] [size=3][font=Consolas]DocumentManager.MdiActiveDocument.Editor.WriteMessage(myNewResBuff.AsArray(I).TypeCode & vbTab & myNewResBuff.AsArray(I).Value.ToString & vbNewLine)[/font][/size] [size=3][color=blue][font=Consolas]Next[/font][/color][/size] [size=3][font=Consolas]AddXData(myVPID, myNewResBuff)[/font][/size] [size=3][color=blue][font=Consolas]End[/font][/color][font=Consolas] [color=blue]Sub[/color][/font][/size] [size=3][color=blue][font=Consolas]End Class[/font][/color][/size] [/font]
×
×
  • Create New...