Results 1 to 5 of 5

Thread: How to get the 'Object ID' of a block while inserting.

  1. #1
    I could stop if I wanted to
    Join Date
    2015-12
    Posts
    385
    Login to Give a bone
    0

    Talking How to get the 'Object ID' of a block while inserting.

    Hello,
    I am trying to use fields to show duct sizing.
    I am in need of finding th 'Object ID' of the block I am inserting.

    If anyone can help, I certainly appreciate it.

    Here is the lisp we have come up with this allows you to get the object id.

    Code:
    (defun c:oid ( / )
      (setq oid (vla-get-ObjectId (vlax-ename->vla-object (car (entsel "\n Select Source Object: ")))))
      (princ (strcat "Object ID = " (rtos oid 2 0) ))
      (princ))

    Thanks again,
    Andre
    Last edited by ReachAndre; 2009-03-02 at 01:34 PM. Reason: [code] tags added

  2. #2
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: How to get the 'Object ID' of a block while inserting.

    You cannot get the object ID while in the process of inserting the object, because it doesn't exist yet. However, as soon as it is placed you can get the object ID of the last object in the current space.
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  3. #3
    I could stop if I wanted to
    Join Date
    2015-12
    Posts
    385
    Login to Give a bone
    0

    Default Re: How to get the 'Object ID' of a block while inserting.

    Rob, thank you for your response, it definately got me thinking. While I was not able to get the object ID while inserting, i was able to obtain the object ID prior to entering the attributes (which was my real need).

    Here is the programming (I have cut out the irrelevent functions)


    Code:
    (defun c:szz (/ cclayer cattdia cdimscale oductw oducth ocfm ofpm osre cdimscale runlay oid displaytext)
      (setq cattdia (getvar "attdia"))
      (setq ductw (getreal "\nEnter duct width: "))
      (setq ducth (getreal "\nEnter duct width: "))
    
      (setvar "attdia" 0)
      
      (command "-insert" "T:\\Mechanical\\Symbols\\Duct Sizing - Rect - Field.dwg" "S" (getvar "Dimscale") pause pause)
    
      (setq oid (vla-get-ObjectId (vlax-ename->vla-object (entlast))))
      (setq displaytext (strcat "\n%<\\AcObjProp Object(%<\\_ObjId "(rtos (+ oid 8) 2 0) ">%).TextString>%"
                                "x"
                                "\n%<\\AcObjProp Object(%<\\_ObjId "(rtos (+ oid 16) 2 0) ">%).TextString>%"))
      (setvar "attdia" cattdia)
    
      (command (rtos ductw 2 0) (rtos ducth 2 0) "XXX" displaytext)  
    
      (princ))
    Thanks,
    Andre
    Last edited by ReachAndre; 2009-03-02 at 01:22 PM.

  4. #4
    I could stop if I wanted to
    Join Date
    2005-09
    Location
    Canada
    Posts
    214
    Login to Give a bone
    0

    Default Re: How to get the 'Object ID' of a block while inserting.

    Quote Originally Posted by ReachAndre View Post
    Rob, thank you for your response, it definately got me thinking. While I was not able to get the object ID while inserting, i was able to obtain the object ID prior to entering the attributes (which was my real need).

    Here is the programming (I have cut out the irrelevent functions)


    Code:
    (defun c:szz (/ cclayer cattdia cdimscale oductw oducth ocfm ofpm osre cdimscale runlay oid displaytext)
      (setq ductw (getreal "\nEnter duct width: "))
      (setq ducth (getreal "\nEnter duct width: "))
    
      (setvar "attdia" 0)
      
      (command "-insert" "T:\\Mechanical\\Symbols\\Duct Sizing - Rect - Field.dwg" "S" (getvar "Dimscale") pause pause)
    
      (setq oid (vla-get-ObjectId (vlax-ename->vla-object (entlast))))
      (setq displaytext (strcat "\n%<\\AcObjProp Object(%<\\_ObjId "(rtos (+ oid 8) 2 0) ">%).TextString>%"
                                "x"
                                "\n%<\\AcObjProp Object(%<\\_ObjId "(rtos (+ oid 16) 2 0) ">%).TextString>%"))
      (setvar "attdia" cattdia)
    
      (command (rtos ductw 2 0) (rtos ducth 2 0) "XXX" displaytext)  
    
      (princ))
    Thanks,
    Andre
    didn't test your code....
    but cattdia variable is not defined..

  5. #5
    I could stop if I wanted to
    Join Date
    2015-12
    Posts
    385
    Login to Give a bone
    0

    Default Re: How to get the 'Object ID' of a block while inserting.

    Quote Originally Posted by andrea.andreetti View Post
    didn't test your code....
    but cattdia variable is not defined..
    Thanks, i fixed this problem on the site, the cattdia was erased during my 'clean up' before my posting irrelevant code.

Similar Threads

  1. Replies: 8
    Last Post: 2015-02-27, 11:50 PM
  2. 2012: Automatic zoom extents after inserting/modifying an AEC object.
    By jeff.greer771012 in forum AMEP General
    Replies: 1
    Last Post: 2012-06-20, 05:31 AM
  3. inserting object
    By seenu_61281 in forum VBA/COM Interop
    Replies: 1
    Last Post: 2009-02-20, 04:13 PM
  4. Keeps Inserting last Block, not the Block selected
    By Buffeldrek in forum AutoCAD General
    Replies: 11
    Last Post: 2007-01-03, 07:57 AM
  5. Replies: 9
    Last Post: 2006-08-24, 09:29 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
  •