TheSwamp

Code Red => VB(A) => Topic started by: MickD on November 30, 2005, 09:44:17 PM

Title: Select modelspace entities in paperspace
Post by: MickD on November 30, 2005, 09:44:17 PM
Hi all,
Does anybody have any code examples of selecting modelspace entities in a viewport from paperspace? (without 'activating' the viewport)

or

Any ideas on the best way to achieve something like this?

TIA,
Mick.
Title: Re: Select modelspace entities in paperspace
Post by: Kerry on December 01, 2005, 05:19:54 AM
[semi-automated unhelpful response]

That sounds like a tricky one Mick.
As you know, I'm not a regularly practicing VBer, but I can't think of any way to achieve this using the ActiveX Object Model.

.. nor with AutoLisp nor the Net API tools.

AutoDesk has found a way in its core 'cause associative dimensioning and object dimensioning allow for object selection in PaperSpace.

If you cant get a definitive answer, I could kick the question upstairs, for whatever that's worth.

good luck

kwb

Title: Re: Select modelspace entities in paperspace
Post by: Kerry on December 01, 2005, 05:31:19 AM
Quote
There is an undocumented ObjectARX function called acedNEntSelPEx()   which may be usable. Itis not officially supported and may be removed or changed at any time.

You may be able to wrap this from a home built COM server ...

.. there may be too many 'mays' in this post :-)

Title: Re: Select modelspace entities in paperspace
Post by: MickD on December 01, 2005, 06:17:48 AM
Thanks Kerry, I have had a brief  look for it before (in the arx lib headers and such) with little luck, I 'may' have to try again :).
I remember something about a picked point being transformed from pspace to mspace and picking an entity 'at that point' using vba or lisp. Having never used (read coded for) paperspace and view ports I'm at a loss and after a bit of a head start if someone has one.
My plans are for .net but I posted here hoping that maybe someone using vba has done something similar to give me a tip or clue on the best way to go about this.
Basically, I want to pick an entity in mspace to attach a leader or item balloon with the entities'  info as the text
Thanks,
Mick.
Title: Re: Select modelspace entities in paperspace
Post by: Kerry on December 01, 2005, 06:29:49 AM
does the ObjectARX acedTrans  transform from paperspace to wcs
Title: Re: Select modelspace entities in paperspace
Post by: Glenn R on December 01, 2005, 07:14:42 AM
What language would you ultimately want this in Mick?

As Kerry pointed out, there is an un-documented function to do this (dimensioning).............

Cheers,
Glenn.
Title: Re: Select modelspace entities in paperspace
Post by: Bob Wahr on December 01, 2005, 10:29:51 AM
I did something a while back, long enough that I need to hunt and refresh, that copied from paperspace to modelspace.  It should be fairly simple to modify.  I'll try to track it down at lunch today and see what I can do with it.
Title: Re: Select modelspace entities in paperspace
Post by: MP on December 01, 2005, 10:32:52 AM
Hi all,
Does anybody have any code examples of selecting modelspace entities in a viewport from paperspace? (without 'activating' the viewport)

or

Any ideas on the best way to achieve something like this?

TIA,
Mick.

Do you mean only selecting entities that are visible in the viewport (i.e. honoring viewport boundaries, clips, vplayer status et. al)?
Title: Re: Select modelspace entities in paperspace
Post by: Kerry on December 01, 2005, 11:04:04 AM
Michael, I'm pretty sure that is the case.
Title: Re: Select modelspace entities in paperspace
Post by: Jürg Menzi on December 01, 2005, 11:33:22 AM
Quick and dirty:
Code: [Select]
(defun MeGetEntsInVport ( / ExLoop LolPnt OffSet SelSet UprPnt VptCen VptEnl VptEnt)
 (while (not ExLoop)
  (initget " ")
  (setq VptEnt (entsel "\nSelect viewport: "))
  (cond
   ((= VptEnt "") (setq ExLoop T))
   (VptEnt
    (setq VptEnl (entget (car VptEnt)))
    (if (= (cdr (assoc 0 VptEnl)) "VIEWPORT")
     (progn
      (setq VptCen (reverse (cdr (reverse (cdr (assoc 10 VptEnl)))))
            OffSet (mapcar
                   '(lambda (l) (/ (cdr (assoc l VptEnl)) 2.0)) '(40 41)
                   )
            LolPnt (trans (mapcar '(lambda (c o) (- c o)) VptCen OffSet) 3 2)
            UprPnt (trans (mapcar '(lambda (c o) (+ c o)) VptCen OffSet) 3 2)
            ExLoop T
      )
      (setvar "TILEMODE" 1)
      (setq SelSet (ssget "_C" LolPnt UprPnt))
      (setvar "TILEMODE" 0)
     )
     (prompt " selected entity is not a viewport.")
    )
   )
   (T (prompt " 1 selected, 0 found."))
  )
 )
 SelSet
)
...Edited: Oops, wrong language
Title: Re: Select modelspace entities in paperspace
Post by: MickD on December 01, 2005, 03:34:43 PM
Thanks All for your replies.

What language would you ultimately want this in Mick?

As Kerry pointed out, there is an un-documented function to do this (dimensioning).............

Cheers,
Glenn.

Ultimately I'd like to do it in C#, the only problem with the undocumented function as pointed out it may become obselete(?).



Do you mean only selecting entities that are visible in the viewport (i.e. honoring viewport boundaries, clips, vplayer status et. al)?

Pretty much Michael, I'd like to pick an entity in ms while in ps, say a block with att's, and use its att's for an item number on a leader or item balloon.

Thanks Jürg, I haven't used lisp in a long time, I'll give it a whirl and let you know.

TA,
Mick.
Title: Re: Select modelspace entities in paperspace
Post by: MickD on December 01, 2005, 05:43:04 PM
Thanks again Jürg but I don't want to change spaces, maybe I ask too much.

Thinking about it though, I think I need to do a 'ray trace' of the point picked in the vp. To do this I have to find where the viewport resides in model space. find the picked point in regards to the vp in mspace, create a ray perpendicular to the vport and find what it 'hits' and grab that entity's id and process it.
Sounds easy ???

Back to the developers guide....
Title: Re: Select modelspace entities in paperspace
Post by: fxcastil on December 08, 2005, 01:15:20 PM
Did you ever get a solution to this problem. I see where you were adding balloons to paper space for items picked in model space.

I am doing the same thing , I just have a user form pop up when the user wants to add leaders with ballons , on the form is an option to pick
items in model space. The user is switched to model space to pick objects when he is done picking objects from the screen I switch back to paper space to add the leaders and balloons. I have not had complaints from users.

What did you decide to do ?

Fred Castillo
Title: Re: Select modelspace entities in paperspace
Post by: MickD on December 08, 2005, 04:02:36 PM
Still working on it Fred, I've been a little distracted with work and other projects of late.
Your solution is fine as is Jürg's but I really want the items to be picked from paperspace without switching modes (or at least the user not seeeing it happen anyway ;) ). The reason is I want the user (i.e. the Drafters in my office) to pick the item and place the item balloon right next to it. This 'almost' eliminates balloons being put in the wrong places.

Hmmm, just a thought, I could probably get a list of the objects from modelspace (while in pspace), put them in a list in a dialog, select the item I want to attach balloons to which highlights the object then place the balloon next to the highlighted item.

That just might work!
Title: Re: Select modelspace entities in paperspace
Post by: Arizona on December 09, 2005, 06:56:20 AM
Mick,

If you had the Cadencoding libraries, try reading this one...CADEncoding\Archives\expresso\cafe\t-5406.html
Title: Re: Select modelspace entities in paperspace
Post by: MickD on December 09, 2005, 04:03:56 PM
Thankyou Arizona, I'll see if I can track it down.
Title: Re: Select modelspace entities in paperspace
Post by: hyposmurf on December 09, 2005, 05:16:47 PM
I've managed to select model space entities in paper space.I have no idea hoiw it happened  but the files were translated from Microstation.Other weird things like not being able to view inserted blocks in the drawing.If I can find one of those wacky drawings I'll stick it in the Lilly pond.