Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/18/2024 in all areas

  1. @pkenewell Very good remark! I had only briefly tested my function and I missed this situation. Thank you for your correction which resolves this problem.
    1 point
  2. @Tsuky Good Job. I did notice a bug however, and I am not sure why it is behaving like this. Try running your command on an MTEXT object that has only 1 field with no other text around it. For some reason it will kill the Field object, leaving behind "####" or "---". EDIT: I figured it out - thanks to reviewing Lee Mac's FieldArithmetic program. You need to clear the text contents before re-adding them for some reason. (defun c:foo ( / ss n ent obj old new) (defun string-subst (nam_obj / value_string nbs tmp_nbs) (setq value_string (vla-fieldcode nam_obj) nbs 0) (while nbs (if (setq nbs (vl-string-search "%pr0" value_string (setq tmp_nbs nbs))) (setq value_string (vl-string-subst "%pr2" "%pr0" value_string tmp_nbs) nbs (1+ nbs) ) ) ) (vlax-put nam_obj 'TextString "") ;; Add this line (vlax-put nam_obj 'TextString value_string) ) (setq ss (ssget '((0 . "MTEXT")))) (cond (ss (repeat (setq n (sslength ss)) (setq ent (ssname ss (setq n (1- n))) obj (vlax-ename->vla-object ent) ) (string-subst obj) ) ) ) (prin1) )
    1 point
  3. Just a guess but ssget didn't find anything so ssbo is nil. When calling sslenght on line 479 its looking at nil rather then a selection set and errors. Add an if in front of the ssget. So if it doesn't find anything it skips the code. (if (setq ssbo (ssget '((0 . "LWPOLYLINE") (8 . "BATAS BIDANG")))) (repeat (setq slbo (sslength ssbo)) ... ... (setq klikpolykor (list entbo korbo)) ) ) -edit Its best to post the whole code. Something else could be happening. Its like taking your car the the mechanic but only letting him look at it from 20' away or at a picture and then asking whats wrong.
    1 point
  4. Hi Satya, Did you work this out? As a stand alone line it works on my CAD.
    1 point
×
×
  • Create New...