AutoCAD .NET :: Change Active Document Window Size
Sep 20, 2012
I'm trying to change the active document window size with vb.net. This seems like it should be straightforward, but I'm having some trouble. Below is some code that I tried to use which I found on the AutoCAD DevBlog.. I thought I understood how this works, but I can't seem to import the correct references to make it work.
Dim doc As Document = Application.DocumentManager.MdiActiveDocument()
Dim docWindow As Window = doc.Window
Dim size As Size = docWindow.Size
docWindow.WindowState = Window.State.Normal
docWindow.Size = New Size(500, 500)
Apparently, in the CS3 is impossible to do any scripting and using any actions. Can it be done using plugins sdk, without creating a new document? I tried using the functions SetPageSetup and SetCropBox but no effect
Is there event for change current (active) layer of document?
(it's not Database.ObjectModified - it's not raised).
I tried to do it with binding as:
public void Initialize() { var layerList = Application.UIBindings.Collections.Layers; layerList.PropertyChanged += new PropertyChangedEventHandler(LayerList_PropertyChanged);
And -= in Terminate, but... Autocad 2012 chashed _sometimes_!!!
Impossible to understand when it happened. So I reject this way. Is there other way to handle this event?
It does almost what I need it to do. except that it also copies the ".ai" in to the layer name. Is there some way to modify this script to have it exclude or delete the file extension?
However, when the state of window the window is changed the text is re over to the document full name. I also use the AcadDocument WindowChanged event,but it is not use.
Everytime I open a document in Photoshop CS5, these 2 dialog boxes (Image Size, Script Alert) would pop up. to cancel 2 times to start editing. Is there a setting I can disable this?
Sometimes when we place a window in a wall we can grab the grip and stretch it to any size we want. Other times the only sizes we can use are the standard sizes. I know how to add a standard size but how can we make it to where you can just strectch it to any size we want?
This code works with no errors but does not change the text size. A user can over ride the text size (Font size) so I'm hoping it is possible thru code.
Dim oSketch As Inventor.Sketch Set oSketch = oPartDoc.ComponentDefinition.Sketches("Sketch1") Dim oText As Inventor.TextBox Set oText = oSketch.TextBoxes.AddByRectangle(pnt1, pnt2) oText.Style.FontSize = 0.1
How can I stop changing active document? I was thinking I could use this, but I don't know how to cancel it in the event handler:
AcadApp.DocumentManager.DocumentToBeActivated += new DocumentCollectionEventHandler(DocumentManager_DocumentToBeActivated);static void DocumentManager_DocumentToBeActivated(object sender, DocumentCollectionEventArgs e){ // Messagebox to ask if user are sure bool AreYouSureYouWantToChangeActiveFile = MessageBox.... if(!AreYouSureYouWantToChangeActiveFile) //cancel change active file somehow...???}
I would like to turn off all the existing layers in active document. I have found in developer's guide how to turn off one layer with specified layer name but can not apply it on all layers with any layername.
I tried to get all the Object ID's in layer table and then for each object turn layer off but seems that it does not work.
<CommandMethod("FilterLayers")> _Public Sub FilterLayers()'' Get the current document and databaseDim acDoc As Document = Application.DocumentManager.MdiActiveDocumentDim acCurDb As Database = acDoc.Database'' Start a transactionUsing acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()'' Open the Layer table for readDim LayerTable As LayerTable = acTrans.GetObject(acCurDb.LayerTableId, OpenMode.ForRead)Dim LayerTableRecord As LayerTableRecord = acTrans.GetObject(LayerTable.ObjectId, OpenMode.ForWrite)For Each ObjectId In LayerTableLayerTableRecord.IsOff = TrueNext'' Save the changes and dispose of the transactionacTrans.Commit()End UsingEnd Sub
I have an external drawing processor and one of the functions is to read the layers in an AutoCAd drawing and if the name matches freeze/thaw it. With modifications over the years I have had it working with 2002 through 2008. Now I'm getting errors. When I tru to use the Interop, I get "Call Rejected by Callee" errors, when I use the
ApplicationServices method to get the application and active document, I getI" Method 'GetEnumerator' in type 'Autodesk.AutoCAD.DatabaseServices.LayerTable' from assembly 'Acdbmgd, Version=18.2.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation." errors.
Basically for the interop method I use this
Imports Autodesk.AutoCAD.Interop Public Function GetAcadApp() As AcadApplication Dim progID As String = My.Settings.strAcadProgID Dim acApp As AcadApplication =
I'm trying to get the value of the Category iproperty of the model on the active drawing sheet. This is not a problem in a single sheet drawing, but I'm not sure how to specifically retrieve the Referenced Document of the Active Sheet in s multi sheet drawing.
Here's what I have:
Option Explicit
Public Sub PartsListFilter()
'set reference to the drawing document 'assumes that a drawing is active Dim oDraw As DrawingDocument Set oDraw = ThisApplication.ActiveDocument [code]........
Why in CS6 when zoom changes window size and a floating window fits in Photoshop window or on other display screen do I get scroll bars where a select all selection marching ants are not visible on all four sides till I drag out the window to get rid of the scroll bars so I can see all of marching ants.
In previous versions of Photoshop space for scroll bars is present but there are no scroll bar, select all marching ants are visible on all four sides when an image's window fits in Photoshop window or on second display. Is there a way to make CS6 work like previous versions? Also if I just open a document and Photoshop fits it to Photoshop window or second display the floating window is correct without scroll bars.
For some reason, when using publish in 2012, it keeps taking me out of whatever window I have active at the moment. In all my versions of cad, I've never once had this issue.
Have been working on a little something and would like to know what units the user is using in their document. Basically what is selected here:
The thing is, no matter what is there (and while all other menus and such use the units) Active Document.unit stubbornly returns inches. Is there a way to get the proper ones using VBA?
Is there a script to convert a layer or layer group to a 32-bit image rather then the entire active document at present that is the only option in Ps 5.x.
I'm working with our new copy of AutoCAD 2013 and using the Visual LISP IDE to create code. I also have an AC2009 machine right next to me for other tasks. On the 2013 machine when I click the "Load Active Edit Window" button it switches to the console screen but there are no messages printed like:
$ ; 37 forms loaded from #<editor "C:/LISP/My-Lisp.lsp"> _$
This of course is making it extremely difficult to debug. I have checked the environment settings and they are exactly the same on each machine. The AC2009 machine prints the messages but the AC2013 machine is just giving me a blank console screen.
In the program window, it looks like its been pushed way in on the full image in the source window. No matter what I do, I can't get it to appear the same as in the source window...
Changes all dimensions, balloons, ect (define more if you want) to current object default in active standard.
Sub ChangeDimStyle()'J.Kriek 2012 Dim oApp As Application Dim oIdw As DrawingDocument Dim oDim As DrawingDimension Dim oBalloon As Balloon Dim oDimStyle As DrawingStandardStyle Dim oSheet As Sheet Set oApp = ThisApplication
I am trying to have one drawing with B size and E size sheets I am trying to get the border, title block and standard to change when the sheet format changes. I can get it to work when I run the rule but have hard time find information to just change when sheet format changes. And I can't find anything or I should say a sample of how to. I think I found the code just don't know how to make it work. Here is what I have so far.
how do i match on screen document size to view print size? when i create a new document and put in its dimensions when i press view print size it appears alot smaller on screen