Farsin Posted May 17, 2020 Posted May 17, 2020 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 Quote
hanhphuc Posted May 18, 2020 Posted May 18, 2020 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 Quote
Farsin Posted May 18, 2020 Author Posted May 18, 2020 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 Quote
Farsin Posted May 18, 2020 Author Posted May 18, 2020 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 Quote
hanhphuc Posted May 19, 2020 Posted May 19, 2020 (edited) 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 May 19, 2020 by hanhphuc snippet added Quote
Farsin Posted May 19, 2020 Author Posted May 19, 2020 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. 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.