See the top rated post in this thread. Click here

Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: Error code since version 2022

  1. #11
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Default Re: Error code since version 2022

    Hi Opie
    Since you are the administrator, I thought I should ask you. So it appears that the issue I am encountering has something to do with existing dynamic blocks in the drawing being manipulated with code after it has been inserted. This problem did not exist prior to version 2022 when I first encountered it. It worked in 20220 and since I skipped 2021, I don't know if that version had issues. I find it incredibly odd that I have to use entmakex to insert existing blocks in these current versions. I have hundreds and hundreds of lines of code that I have to revise to make work. Some of them I cannot make work using entmakex. Is there a way that I can report this issue to Autodesk? Thank you for you help with this.
    Manuel

  2. #12
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: Error code since version 2022

    Just because I am an administrator of the forums does not mean I need to be the one to answer your inquiry. There are many knowledgeable members of the forums that may have the answer you are seeking. However, they are also volunteering their time to help when they are available.

    I did try your code. It worked with the side affect of that error message. Other than the message, the desired result was provided in the drawing using your code and supplied block. There are other ways to insert a block into the current drawing space. Using the command function as you are currently using is one way. Another way may be to use a VLA-InsertBlock method for the active space. I can't code that at the moment, but it may resolve your problem.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #13
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Default Re: Error code since version 2022

    Hi All
    At Opie's suggestion, I tried the vla-insertblock method and it seems to work well. Now I am trying to build an insert block sub-routine with attribute support. Here's what I have thus far. The executable would be something like (cm:insertblock inspt (CM:A "sectiontag") 1.0 1.0 1.0 0 nil). What I would like to do is make the last value be a dotted pair where the first field is the attribute tag name and the second field is the new value. I want the final executable to look like this: (cm:insertblock inspt (CM:A "sectiontag") 1.0 1.0 1.0 0 '(("DETNUM" . detno)("SHTNUM" . shtno))). This would allow me to expand the attribute list as needed. Any help is greatly appreciated. Thanks.
    Manuel

    Code:
    (defun cm:insertblock (inspt blkpath xscl yscl zscl rot attlist / msp)
    (vl-load-com)
      (setq msp (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))
            blkname (vl-filename-base blkpath)
      )
      (setq blk (vla-InsertBlock msp (vlax-3d-point inspt) blkname xscl yscl zscl rot))
      (if (and (/= attlist nil)(setq atts (vlax-invoke blk 'GetAttributes)))
        (progn
          (vla-put-TextString (car atts) detno)
          (vla-put-TextString (cadr atts) shtno)
        )
      )
    )

  4. #14
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: Error code since version 2022

    As the returned inserted block reference is an object, you can check the HasAttributes property to see if it equals :vlax-true. Once you know that block has attributes, you will need to convert the safe list into a list of attributes for which you can then use a FOREACH loop and use the TagString property of each attribute object to retrieve the ASSOCiated list item from your supplied attribute dotted pair list "attlist" to set the TextString property of the attribute object.

    Also, in your cm:insertblock routine, I would supply as an argument the space (model, paper, or other block object). This would allow you to use the routine in other than model space.
    Last edited by Opie; 2022-06-30 at 04:06 PM.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  5. #15
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Default Re: Error code since version 2022

    Does vla-insertblock only work with block that are already in the drawing or can it used it to insert new blocks ? Thanks
    Manuel

  6. #16
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: Error code since version 2022

    It can insert a drawing file as a block. You will need to add the .dwg file extension when doing so.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  7. #17
    I could stop if I wanted to
    Join Date
    2005-06
    Location
    CORDOBA-ARGENTINA
    Posts
    275
    Login to Give a bone
    0

    Default Re: Error code since version 2022

    There is NO block at the drawing , it are BLOCKREFERENCEs

    as per acad lisp help

    InsertBlock Method (ActiveX)



    Inserts a drawing file or a named block that has been defined in the current drawing.

    Supported platforms: Windows only

    Signature
    VBA:

    RetVal = object.InsertBlock(InsertionPoint, Name [, Xscale [, Yscale [, ZScale [, Rotation [, Password]]]]])object
    Type: Block, ModelSpace, PaperSpace

    The objects this method applies to.

    InsertionPoint
    Access: Input-only

    Type: Variant (three-element array of doubles)

    The 3D WCS coordinates specifying the location in the drawing to insert the block.

    Name
    Access: Input-only

    Type: String

    The name of the AutoCAD drawing file or the name of the block to insert. If it is a file name, include the .dwg extension and any path information necessary for AutoCAD to find the file.

    Xscale
    Access: Input-only; optional

    Type: Double

    The default equals 1.0. Must be a positive number.

    Yscale
    Access: Input-only; optional

    Type: Double

    The default equals 1.0. Must be a positive number.

    Zscale
    Access: Input-only; optional

    Type: Double

    The default equals 1.0. Must be a positive number.

    Rotation
    Access: Input-only; optional

    Type: Double

    The default equals 0.0 radians.

    Password
    Access: Input-only; optional

    Type: Variant

    The password that was applied to the drawing file when it was saved.

    Return Value (RetVal)
    Type: BlockReference

    The placed block as a Block Reference object.

    Remarks
    Inserting a block into another block will create nested blocks.

    Attempting to call the InsertBlock method with an uninitialized Name parameter results in unexpected behavior.

    Examples
    VBA:

    Sub Example_InsertBlock()
    ' This example creates a block containing a circle.
    ' It then inserts the block.

    ' Create the block
    Dim blockObj As AcadBlock
    Dim insertionPnt(0 To 2) As Double
    insertionPnt(0) = 0#: insertionPnt(1) = 0#: insertionPnt(2) = 0#
    Set blockObj = ThisDrawing.Blocks.Add(insertionPnt, "CircleBlock")

    ' Add a circle to the block
    Dim circleObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 0: center(1) = 0: center(2) = 0
    radius = 1
    Set circleObj = blockObj.AddCircle(center, radius)

    ' Insert the block
    Dim blockRefObj As AcadBlockReference
    insertionPnt(0) = 2#: insertionPnt(1) = 2#: insertionPnt(2) = 0
    Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "CircleBlock", 1#, 1#, 1#, 0)


    ZoomAll

    End SubVisual LISP:

    (vl-load-com)
    (defun c:Example_InsertBlock()
    ;; This example creates a block containing a circle.
    ;; It then inserts the block.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Create the block
    (setq insertionPnt (vlax-3d-point 0 0 0))
    (setq blockObj (vla-Add (vla-get-Blocks doc) insertionPnt "CircleBlock"))

    ;; Add a circle to the block
    (setq center (vlax-3d-point 0 0 0)
    radius 1)
    (setq circleObj (vla-AddCircle blockObj center radius))

    ;; Insert the block
    (setq insertionPnt (vlax-3d-point 2 2 0))
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq blockRefObj (vla-InsertBlock modelSpace insertionPnt "CircleBlock" 1 1 1 0))

    (vla-ZoomAll acadObj)
    )

  8. #18
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    1

    Default Re: Error code since version 2022

    Quote Originally Posted by devitg.89838 View Post
    There is NO block at the drawing , it are BLOCKREFERENCEs

    as per acad lisp help
    This seems to be more about semantics. Drawings do contain blocks, which are definitions of "blocks" of geometry. To use those "blocks", one would then use references or inserts of that definition.

    The vla- method is using the block word in the method name of vla-insertblock. This method allows for the insertion of drawings as block definitions if necessary.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  9. #19
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Error code since version 2022

    Here is an example on how to use vla-InsertBlock to insert an external drawing as suggested by Opie.

    https://www.cadtutor.net/forum/topic...comment-506366

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Old code not working in AutoCAD 2022
    By cadconcepts in forum AutoLISP
    Replies: 6
    Last Post: 2021-09-14, 07:45 PM
  2. 2021: 2022 issues
    By rmk in forum AutoCAD Civil 3D - General
    Replies: 2
    Last Post: 2021-06-23, 12:40 PM
  3. What’s new in Revit 2022
    By amit.sondagar795716 in forum Revit Architecture - General
    Replies: 3
    Last Post: 2021-05-18, 01:35 PM
  4. 2021: Fix for missing Fabrication Add-ins for Revit 2022
    By Darren J. Young in forum Revit MEP - General
    Replies: 1
    Last Post: 2021-05-04, 12:56 PM
  5. Replies: 2
    Last Post: 2005-12-28, 04:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •