Selecting objects by Page and Layer

Selecting objects by Page and Layer

nicolasR6NGC
Contributor Contributor
1,900 Views
22 Replies
Message 1 of 23

Selecting objects by Page and Layer

nicolasR6NGC
Contributor
Contributor

Hi I'm trying to use ssget to select a polyline that controls a viewport and move it from one page to another. However, no matter what I do my script only selects the first viewport and copies that across all pages instead. Any ideas what is wrong with these lines?

 

 (setq min-point (list -1e9 -1e9 0)) ; Define a very large minimum point
(setq max-point (list 1e9 1e9 0)) ; Define a very large maximum point
(setq viewport-entity (ssget "C" min-point max-point '((0 . "POLYLINE") (8 . "-VPORT")))) 

0 Likes
Accepted solutions (1)
1,901 Views
22 Replies
Replies (22)
Message 2 of 23

paullimapa
Mentor
Mentor

are you sure you have a POLYLINE there that's also on layer "-VPORT"

could you share your dwg here?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 23

john.uhden
Mentor
Mentor

@nicolasR6NGC ,

Umm, is your polyline in Modelspace or in another layout?

John F. Uhden

0 Likes
Message 4 of 23

nicolasR6NGC
Contributor
Contributor

It's in paper space

0 Likes
Message 5 of 23

nicolasR6NGC
Contributor
Contributor

There definitely is one the problem is that the script is copying the same one over and over.

0 Likes
Message 6 of 23

paullimapa
Mentor
Mentor

Please share your entire code here 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 7 of 23

nicolasR6NGC
Contributor
Contributor

I'm currently still working on it so it isn't working completely yet but this code will utilize a command developed by my coworker that creates pages in the same manner as saved in the dwg I shared. The idea is that since the page format is hard coded as the one shown in 100 onwards we would get around this by running this command to copy and paste the created VPs onto a copy of the proper format saved in the dwg as master. Sometimes it will generate 1 VP per page and sometimes 2 VP depending on the users input.

0 Likes
Message 8 of 23

paullimapa
Mentor
Mentor
Accepted solution

Just checked your drawing. The POLYLINE is on a different Layer name "-VPORT-FRAME" and with LISP the POLYLINE object is identified as "LWPOLYLINE":

paullimapa_0-1738179998213.png

So changing your line of code to this will then be able to select the POLYLINE on layer -VPORT-FRAME:

 

(setq viewport-entity (ssget "C" min-point max-point '((0 . "LWPOLYLINE") (8 . "-VPORT-FRAME"))))

 

But since you're basically looking for that POLYLINE in the entire current layout then you might as well use this code without having to bother with "C" option but just use the "X" option adding the ctab variable which selects everything only in current layout:

 

(setq viewport-entity (ssget "_X" (list '(0 . "LWPOLYLINE") '(8 . "-VPORT-FRAME") (cons 410 (getvar "ctab")))))

 

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 9 of 23

nicolasR6NGC
Contributor
Contributor

The polyline I'm looking for is the one that is over the viewport not the grey one. Still I wasn't sure how to select by current layout so the solution was exactly what I needed regardless, thanks!

0 Likes
Message 10 of 23

paullimapa
Mentor
Mentor

glad that worked out for you...cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 11 of 23

nicolasR6NGC
Contributor
Contributor

Hi I replaced the code and it is coping only with the first viewport can you explain to me how the cons 410 section?

0 Likes
Message 12 of 23

paullimapa
Mentor
Mentor

cons 410 (getvar”ctab”) limits selection of objects in current layout only. I assume this is what you want since you don’t want to select the vports in all the other layouts.  This code only selects the vport in the current layout. Then looking at the rest of the code it finds the center point of the vport and then copies it and paste into another layout tab. Not sure why you want the center point as the base for the copy. Why not just 0,0 since all the other 100 numbered layouts are placed in the same coordinate location?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 13 of 23

nicolasR6NGC
Contributor
Contributor

We want to find the center for the viewport since the sheet size may vary between the sheet the vp is being copied from and where it is being pasted to. Also the vps themselves will vary in size as well. I tried editing the code with this new line and it isn't selecting anything anymore and I can't seem to get cons 410 to work.

0 Likes
Message 14 of 23

paullimapa
Mentor
Mentor

Share your revised code with this new line added


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 15 of 23

nicolasR6NGC
Contributor
Contributor

Here is the revised version.

0 Likes
Message 16 of 23

paullimapa
Mentor
Mentor

your code still shows this which does not exist:

(0 . "POLYLINE")

everywhere this shows up needs to be replaced with this which I mentioned in my previous post:

(0 . "LWPOLYLINE")

also I see this:

(setq viewport-selection (ssget "X" '((0 . "POLYLINE") (8 . "-VPORT") (2 . current-layout)))) ; Select viewports on the -VPORT layer

This won't work also because there's no such thing as (2 . ) 

So again should be relaced with this:

(setq viewport-entity (ssget "_X" (list '(0 . "LWPOLYLINE") '(8 . "-VPORT") (cons 410 (getvar "ctab")))))

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 17 of 23

nicolasR6NGC
Contributor
Contributor

I see it is running fine now thank you! Is there a way outside of LISP to display whether something is a polyline or a LWpolyline? I thought since we were coping different lines perhaps the one I was using is a polyline but it was still an LWpolyline.

0 Likes
Message 18 of 23

paullimapa
Mentor
Mentor

Without lisp one way would be to look for the documentation Online like this one:

https://help.autodesk.com/view/ACDLT/2024/ENU/?guid=GUID-ECB6F2FF-6680-4514-86A7-7AD5551E378D

@nicolasR6NGC but that only lists on the possible object names. You’ll still have to use lisp to determine what the object is actually named


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 19 of 23

cadffm
Consultant
Consultant

In properties palette / CTRL+1

LWPOLYLINES are POLYLINE

POLYLINES are 2D-POLYLINE

 

And in command LIST you can see it aswell.

Sebastian

0 Likes
Message 20 of 23

cadffm
Consultant
Consultant

And offtopic: Read also about PLINTYPE [F1]

 

Sebastian

0 Likes