Jump to content

Object ID varies in different lisp outputs


Farsin

Recommended Posts

hi, i was trying to label polylines with their object ids using ll-Label A line with its own id.lsp and get table with object ids and lengths of polyline using test length ID.lsp but the id labelled by the first lisp and the id in the table varies. the ids labelled on the polylines are long number with many digits and in the table its a 3 digit number.

im attaching a sample dwg file also with polylines labelled with object ids and table with lengths and object ids

 

thank you!

Drawing2.dwg

Link to comment
Share on other sites

The only different

in table lsp which vla-settext objectid without itoa

whereas field lsp  with (itoa objectid )

 

Bricscad returns both Long integer & string

not sure but here's my simple test

(setq en (car(entsel "\nSelect entity ")))
(setq obj (vlax-ename->vla-object en) )

(vla-get-objectid obj)
;1639387728
(itoa (vla-get-objectid obj))
;"1639387728"
(vl-princ-to-string (vla-get-objectid obj))
;"1639387728"
(atoi (itoa (vla-get-objectid obj)))
;1639387728 

 

 

 

 

 

Link to comment
Share on other sites

thank you for the response.

im very new to the lisp programs and i didnt quite understand how to use the code you provided.

excuse my ignorance, which part of the original code should be changed like this?

 

regards

Link to comment
Share on other sites

i think i just found a solution to my problem. i was looking for a way to get a common thing to identify the same object in the table and label. so that i can look for an object in the drawing corresponding to its property in the table. i just read in another forum that Object id varies session to session. so if i export the table to excel or copy the details somewhere else or open the drawing in another session, the values will not match. to serve my purpose, i will have to use handle instead of objectID. just modified both programs and it works. both return same value in label and table. attaching the lisp files and dwg here so that it might help someone else.

 

thank you hanhphuc for your response

test Handle.lsp ll-Label A line with its own handle.lsp Drawing.dwg

Link to comment
Share on other sites

10 hours ago, Farsin said:

thank you for the response.

im very new to the lisp programs and i didnt quite understand how to use the code you provided.

excuse my ignorance, which part of the original code should be changed like this?

 

regards

 

 

That code i was trying to debug/replicate the issue which you mentioned difference of 3 digits with long value (many digits)?

 

to open LISP editor

command: VLIDE 

test in console observe the output value

 

IIRC for ACAD (BCAD not supported)

command: LSP

console ? 

 

yes, HANDLE  is unique, objectID may change

 

since it other "l-Label A line with its own id.lsp"  supports Arc selection? 

so "test length ID.lsp" you may include Arc in selection set 

(setq s (ssget '((0 . "LWPOLYLINE,LINE,ARC"))))

 

For your "test length ID.lsp"

i would suggest FIELD associative length in table if polyline modified,  command: REGEN  to update value in your table

FIELD snippet is from this -> old thread

p/s: can't work in BCAD,  but the FIELD snippet previously run well in ACAD.

here's FIELD snippet to be applied in while loop

 

(while (setq e (ssname s (setq r (1+ r))))
  (if e
    (progn
      (setq e (vlax-ename->vla-object e))
      (vla-settext objtable Y 0 (rtos x 2 0))
      (vla-settext
        objtable
        Y
        1
        (strcat "%<\\AcExpr (%<\\AcObjProp Object(%<\\_ObjId "
                (itoa (vla-get-ObjectID e))
                ">%)."
          (if (vlax-property-available-p e 'arclength)
            "arc"
            ""
          )
                "length>%*0.001) \\f %lu2%pr3>%"
        )
      )
      (vla-settext objtable Y 2 (vla-get-handle e))
      (setq x (1+ x))
      (setq y (1+ Y))
    )
  )
)

 

Edited by hanhphuc
snippet added
Link to comment
Share on other sites

Thanks, 

Since I'm new to these things, I'll have to try the lisp editor etc as you mentioned to understand the things you said.

My experience with lisp is just downloading lsp files, open in notepad and make minor edits and run. 

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...