Author Topic: Simple routine request  (Read 6647 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Simple routine request
« on: June 18, 2010, 08:12:15 AM »
Hi all

I want to select an object in all layouts then change entity for?

Example

select all viewports in all layouts
save old value of DXF code 90
add 147456 to old value

thanks for your help
Hasan

kpblc

  • Bull Frog
  • Posts: 396
Re: Simple routine request
« Reply #1 on: June 18, 2010, 08:32:14 AM »
You can use something like (setq selset (ssget "_X" '((0 . "VIEWPORT")))) and work with selection set.
Sorry for my English.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Simple routine request
« Reply #2 on: June 18, 2010, 03:35:43 PM »
thanks kpblc

this was my start
Code: [Select]
(defun c:vps ()
     (setq vprtslct (ssget "X" '((0 . "VIEWPORT"))))
     (foreach x vprtslct
      )
but I lost in foreach and How to select viewport in all layouts.
 

PS: Whats deference between "X" and "_X"

Hasan
« Last Edit: June 18, 2010, 03:46:12 PM by HasanCAD »

kpblc

  • Bull Frog
  • Posts: 396
Re: Simple routine request
« Reply #3 on: June 18, 2010, 03:51:30 PM »
The difference is:
(ssget "X" <...>) -> will work only on english AutoCAD
(ssget "_X" <...>) -> will work on any localised version of AutoCAD (include English)
P.S. To convert selection set to list try to use code like this:
Code: [Select]
(defun conv-selset-to-list (selset / tab item)
  (repeat (setq tab  nil
                item (sslength selset)
                ) ;_ end setq
    (setq tab (cons (ssname selset (setq item (1- item))) tab))
    ) ;_ end of repeat
  ) ;_ end of defun
And then:
Code: [Select]
(setq vprtslct (ssget "_X" '((0 . "VIEWPORT"))))
(foreach (conv-selset-to-list vprtslct)
<...>
  )
Sorry for my English.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Simple routine request
« Reply #4 on: June 18, 2010, 07:26:28 PM »

Quote
(ssget "X" <...>) -> will work only on english AutoCAD
(ssget "_X" <...>) -> will work on any localised version of AutoCAD (include English)

Can someone confirm that the (ssget "X" .. is affected by ' localisation ' issues
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

kenkrupa

  • Newt
  • Posts: 84
Re: Simple routine request
« Reply #5 on: June 19, 2010, 12:03:46 PM »
Can someone confirm that the (ssget "X" .. is affected by ' localisation ' issues

Command: (ssget "X")
<Selection set: 3>

Command: globcheck
Enter new value for GLOBCHECK <0>: 1

Command: (ssget "X")
The ssget option string must be preceded by an underscore.
Localization unfriendly ssget option "x" rejected!

kpblc

  • Bull Frog
  • Posts: 396
Re: Simple routine request
« Reply #6 on: June 19, 2010, 01:24:58 PM »
I can't find full description of system variable 'globcheck'. Could you help me please?
Sorry for my English.

LE3

  • Guest
Re: Simple routine request
« Reply #7 on: June 19, 2010, 01:31:56 PM »
I can't find full description of system variable 'globcheck'. Could you help me please?

Here:
http://www.manusoft.com/resources/acadexposed/sysvars.html

kpblc

  • Bull Frog
  • Posts: 396
Re: Simple routine request
« Reply #8 on: June 19, 2010, 01:44:43 PM »
Thank you very much!
Sorry for my English.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Simple routine request
« Reply #9 on: June 24, 2010, 03:50:17 AM »
(defun c:vps(/ dimsel)
(setq dimsel(ssget "x" '((0 . "VIEWPORT"))))
   (command "_PSELECT" "_p" "")
(PRINC)
)
selected all viewports in all layouts

but entmod not working with viewports
is there any solution?
« Last Edit: June 24, 2010, 03:56:35 AM by HasanCAD »

Hangman

  • Swamp Rat
  • Posts: 566
Re: Simple routine request
« Reply #10 on: June 24, 2010, 02:40:52 PM »
Quote
AutoLISP Reference Guide > AutoLISP Functions > E Functions >

entmod

Modifies the definition data of an object (entity)
 <...>

Restrictions on Using entmod

There are restrictions on the changes the entmod function can make:
<...>
*** You cannot use the entmod function to modify a viewport entity. ***


Sorry, no-can-do with Entmod.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hangman

  • Swamp Rat
  • Posts: 566
Re: Simple routine request
« Reply #11 on: June 24, 2010, 02:45:33 PM »
Here's an excerpt taken from CAB's 'VPLockAll',
Code: [Select]
(if (= (vla-get-objectname ent) "AcDbViewport")
          (progn
            (vla-put-displaylocked ent lck)
            (vla-put-color ent clr)
            (if (setq obj (assoc 340  (entget (vlax-vla-object->ename ent))))
              (vla-put-color (vlax-ename->vla-object (cdr obj)) clr2)
            )
          ); end progn
        )

I know the viewport is accessed and it is locked or unlocked, and the color is changed depending on the scenario, but this is the only manner I have seen so far in modifying viewports.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Simple routine request
« Reply #12 on: July 02, 2010, 09:31:20 AM »
what about this

Code: [Select]
(defun c:vps(/ VPsel)

  (foreach x (setq VPsel(ssget "_X" '((0 . "VIEWPORT"))))
    (vla-put-displaylocked VPsel :vlax-false)
            )
  (PRINC)
  )

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Simple routine request
« Reply #13 on: July 02, 2010, 09:34:23 AM »
what about this

Code: [Select]
(defun c:vps(/ VPsel)

  (foreach x (setq VPsel(ssget "_X" '((0 . "VIEWPORT"))))
    (vla-put-displaylocked VPsel :vlax-false)
            )
  (PRINC)
  )

You'll have to turn your selection set into a list to perform foreach on it.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Simple routine request
« Reply #14 on: July 02, 2010, 09:40:31 AM »
You'll have to turn your selection set into a list to perform foreach on it.

Is this correct way
Code: [Select]
(defun c:vps(/ VPsel)

  (foreach x (setq VPsel (list (ssget "_X" '((0 . "VIEWPORT")))))
    (vla-put-displaylocked VPsel :vlax-false)
            )
  (PRINC)
  )
seems not
because not working for me