cadman6735 Posted January 24, 2011 Posted January 24, 2011 I understand that there are 4 types of blocks 1 - Simple Block 2 - Xref Block 3 - Layout Block 4 - Dynamic Block I want to understand Layout Block. I am of the impression that to add a point, line, element etc... using VLA I have to choose either paperspace or modelspace to add my element to. In vanilla lisp the line can be created in the active layout using the DXF codes but Visual lisp requires me to tell it Paper or Model space. (Am I correct in this thinking?) This brings me to Block Layout. I am thinking that Block layout will allow me to not choose wheather the space is model or paper. (not sure, is this correct?) How do I access or use Block Layout? I get an error that Block is an unknown name. (defun C:PlotPoint ( / ) (vl-load-com) (setq acadObject (vlax-get-acad-object) acadActiveDocument (vla-get-ActiveDocument acadObject) acadLayouts (vla-get-Layouts acadActiveDocument) acadLayoutBlock (vla-get-Block acadLayouts) ) ;----------------------------------------------------------------------------------------- (vla-StartUndoMark acadActiveDocument) ;Start of UNDO ;----------------------------------------------------------------------------------------- (setq PlotPoint_1 (getpoint "\nPlace First Plot Point")) (vla-addpoint acadLayoutBlock (vlax-3D-point PlotPoint_1)) (setq PlotPoint_2 (getpoint "\nPlace Second Plot Point")) (vla-addpoint acadLayoutBlock (vlax-3D-point PlotPoint_2)) ;----------------------------------------------------------------------------------------- (vla-EndUndoMark acadActiveDocument) ;End of UNDO ;----------------------------------------------------------------------------------------- (princ) ) Thanks Quote
Lee Mac Posted January 24, 2011 Posted January 24, 2011 Consider this code: (defun c:PlotPoint ( / acadLayoutBlock p1 ) (vl-load-com) (setq acadLayoutBlock (vla-get-Block (vla-get-ActiveLayout (vla-get-ActiveDocument (vlax-get-acad-object)) ) ) ) (if (setq p1 (getpoint "\nSpecify Point: ")) (vla-AddPoint acadLayoutBlock (vlax-3D-point p1)) ) (princ) ) Note that your code accesses the Layouts Collection, not a specific Layout item. However the above code will not account for users viewing ModelSpace through a Viewport in Paperspace. To be sure to add the object to the correct space, perhaps study these examples. Quote
Lee Mac Posted January 24, 2011 Posted January 24, 2011 In vanilla lisp the line can be created in the active layout using the DXF codes but Visual lisp requires me to tell it Paper or Model space. (Am I correct in this thinking?) Correct. This brings me to Block Layout. I am thinking that Block layout will allow me to not choose wheather the space is model or paper. (not sure, is this correct?) Not so much that it won't allow you to choose the space, by accessing the 'Layout Block' you have already chosen - if you access the Block property of the Model Layout, you are effectively accessing the ModelSpace block; and vice versa. Quote
BlackBox Posted January 24, 2011 Posted January 24, 2011 From the Developer Help: Layout object The plot settings and visual properties of a model space or paper space block. VBA class name: AcadLayout Create using: Layouts.Add Access via: Layouts.Item Document.ActiveLayout ModelSpace.Layout PaperSpace.Layout Block.Layout The representation of a layout is slightly different in ActiveX from that of the AutoCAD user interface. In ActiveX, the content of a standard AutoCAD layout is broken out into two separate objects: Layout object and Block object. The Layout object contains the plot settings and the visual properties of the layout as it appears in the AutoCAD user interface. The Block object contains the geometry for the layout. Each Layout object is associated with one Block object. To access the Block object associated with a given layout, use the Block property. Conversely, each Block object is associated with one Layout object. To access the Layout object associated with a given Block, use the Layout property for that block. In ActiveX, in addition to the paper space layouts, model space is considered a layout. Quote
cadman6735 Posted January 24, 2011 Author Posted January 24, 2011 oooohhhhh, I see. I can't add a point, line, entity etc... to Active Layout but I can add a point to the block of the active layout. The help menu only stated Layout, not Active Layout.... It is mis-leading but all make sense now. Thanks again Lee. Yes, my code is/was accessing the Layout Collection, I tried just Layout but I got an error message saying "unknown name Layout" then I changed it to Layouts, and got the error message, "unknown name Block" the second error message seemed to be closer to the target of my objective. But once again I was wrong and closer with my first error message. :-) Quote
cadman6735 Posted January 24, 2011 Author Posted January 24, 2011 Thanks RenderMan I read the help menu on this too... It is mis-leading because it states to ACCESS Block.Layout But it should say Block.ActiveLayout I am sure I stated this wrong but with my limited knowledge and after reading Lee Macs response and what the help menu states it does seem a bit mis-leading. Quote
Lee Mac Posted January 24, 2011 Posted January 24, 2011 Thanks again Lee. You're welcome Yes, my code is/was accessing the Layout Collection, I tried just Layout but I got an error message saying "unknown name Layout" then I changed it to Layouts, and got the error message, "unknown name Block" the second error message seemed to be closer to the target of my objective. But once again I was wrong and closer with my first error message. :-) As a tip, 'Dump' the properties and methods of the objects to see what's available This may help: http://lee-mac.com/dumpobject.html Quote
cadman6735 Posted January 24, 2011 Author Posted January 24, 2011 sweet, thanks for the link... Yes, I am just starting to use OjectDump and entget functions to eplore elements and objects. But I still need more practice, I only discovered how useful these functions are this past weekend, so I am still weak in using them effectivly. But seeing that I am on the right track is encouraging... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.