Author Topic: Error after completing the command  (Read 819 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Error after completing the command
« on: November 15, 2021, 03:39:48 PM »
I have the following routine which i used to select the viewport and then select the scale bar (attributed block) and it updates the values via fields.

It works but at the end of the command in the command line it shows the following:

Code: [Select]
Pick a viewport:
Select Block: ; error: ADS request error

Not sure why it does this.

Code: [Select]
;;Links the Viewport Scale to the Scale Bar

(defun _getviewport (e)
  (if e
    (cond ((= "VIEWPORT" (cdr (assoc 0 (entget e)))) e)
  ((cdadr (member '(102 . "{ACAD_REACTORS") (entget e))))
    )
  )
)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun c:vpscale-link (/ fldobj util vpid vpobj)
    (if (and (setq vpobj (_getviewport (car (entsel "\nPick a viewport: "))))
   ;; Add a check that it's a viewport selected
   (setq fldobj (car (entsel "\nSelect Block: ")))
   ;; Add a check that it's your barscale selected
   (setq vpid (vla-get-objectid (setq vpobj (vlax-ename->vla-object vpobj))))
      )
    (progn
      (if (> (vl-string-search "x64" (getvar "platform")) 0)
(progn (setq util (vla-get-utility (vla-get-activedocument (vlax-get-acad-object)))
     vpid (vlax-invoke-method util "GetObjectIdString" vpobj :vlax-false)
       )
)
(setq vpid (vl-princ-to-string (vla-get-objectid vpobj)))
      )
      (foreach a '("half" "double" "full2" "full1" "verthalf" "vertfull" "vertdouble" "verthalfrot" "vertfullrot" "vertdoublerot" "tripple")
(setpropertyvalue
  fldobj
  a
  (strcat "%<\\AcExpr ("
  (cond ((= a "half") "2.0")
((= a "double") "0.5")
((= a "full2") "1.0")
((= a "full1") "1.0")
((= a "verthalf") "2.0")
((= a "vertfull") "1.0")
((= a "vertdouble") "0.5")
((= a "verthalfrot") "2.0")
((= a "vertfullrot") "1.0")
((= a "vertdoublerot") "0.5")
((= a "tripple") "0.25")
  )
  "*%<\\AcObjProp Object(%<\\_ObjId " vpid ">%).CustomScale>%) \\f \"%lu2%ct1%qf2816'\">%"  ;;%lu2%ct1%qf2816%ps[,\']">%
  )
)
      )
      (vla-regen (vla-get-activedocument (vlax-get-acad-object)) 1)
    )
  )
 (vla-regen (vla-get-activedocument (vlax-get-acad-object)) 1)
(princ))

Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Error after completing the command
« Reply #1 on: November 15, 2021, 04:50:52 PM »
That block does not have these attribute tagnames : "verthalf" "vertfull" "vertdouble" "verthalfrot" "vertfullrot" "vertdoublerot" "tripple"

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Error after completing the command
« Reply #2 on: November 15, 2021, 05:16:21 PM »
Thanks ron! If the values are not in the block then it would error out.
Civil3D 2020