TheSwamp

CAD Forums => CAD General => Topic started by: MSTG007 on May 19, 2015, 07:53:42 AM

Title: Macro - User Selects Object
Post by: MSTG007 on May 19, 2015, 07:53:42 AM
I am trying to write a simple macro that will reset the visretain on a selected xref and reload it. I know I can get away with it when I reload all (*). How can I get it to where the user would select an object. I know that the user can pick using the (\).

^C^Cvisretain;0;-xref;reload;(USER SELECTS);visretain;1;

Thank you
Title: Re: Macro - User Selects Object
Post by: ronjonp on May 19, 2015, 08:49:17 AM
Look into ENTSEL (http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-9D4CF74D-8B8B-4D66-A952-564AFBA254E7) then use ENTGET (http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-12540DAE-C84B-4BDB-AEEC-DDFE5BE3C42A) and retrieve CODE 2 (http://www.autodesk.com/techpubs/autocad/acad2000/dxf/group_codes_in_numerical_order_dxf_01.htm) with ASSOC (http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-46309786-DAF6-4C28-8448-599FBC8A4F6A).
Title: Re: Macro - User Selects Object
Post by: MSTG007 on May 20, 2015, 07:51:38 AM
Thanks for sharing this. Here is the macro I am messing with below:

The Command I am using:

Code: [Select]
^C^Cvisretain;0;-xref;reload;(setq e (entsel "Please choose an object: "));visretain;1;

The Error I am getting:

Code: [Select]
Command: visretain
Enter new value for VISRETAIN <0>: 0
Command: -xref
Enter an option [?/Bind/Detach/Path/pathType/Unload/Reload/Overlay/Attach] <Attach>: reload
Enter xref name(s) to reload: (setq e (entsel "Please choose an object: "))
Please choose an object: visretain
*Invalid selection*
Expects a point or Last
Please choose an object: nil

Maybe I am not using this in the right sequencing or I need to add more?
Title: Re: Macro - User Selects Object
Post by: ronjonp on May 20, 2015, 09:50:50 AM
Looks like the command line version is expecting a name of the xref to reload so it won't let you pick it in that sequence. Do you know what (ENTSEL (http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-9D4CF74D-8B8B-4D66-A952-564AFBA254E7)) returns?

Here's a fish  ;)

Code - Auto/Visual Lisp: [Select]
  1. (defun c:vr (/ b)
  2.   (if (and (setq b (car (entsel "\nPick an XREF to reload: ")))
  3.            (= (cdr (assoc 0 (entget b))) "INSERT")
  4.                              (cdr (assoc 2 (entget b)))
  5.                    )
  6.            )
  7.            (minusp (vlax-get b 'isxref))
  8.       )
  9.     (progn (setvar 'visretain 0) (vla-reload b) (setvar 'visretain 1))
  10.   )
  11.   (princ)
  12. )
Title: Re: Macro - User Selects Object
Post by: MSTG007 on May 20, 2015, 09:52:24 AM
yup it returns this value

Code: [Select]
Please choose an object: visretain
*Invalid selection*
Expects a point or Last
Please choose an object: (<Entity name: 7ffffb9d880> (188827.0 1.73852e+006 0.0))