Author Topic: Together, but apart....  (Read 9640 times)

0 Members and 1 Guest are viewing this topic.

Water Bear

  • Guest
Together, but apart....
« on: March 29, 2004, 07:31:27 PM »
Does anyone know how I might make a group such that I can move the components around, if required, but can be deleted by selecting any one part? :shock:

Serge J. Gianolla

  • Guest
Together, but apart....
« Reply #1 on: March 29, 2004, 09:47:11 PM »
Use the Group command, and toggle Selectable ON/OFF at will to realise what you're after.

Water Bear

  • Guest
Together, but apart....
« Reply #2 on: March 29, 2004, 10:45:12 PM »
Thanks for the input Serge, but I'm  trying to accomplish it in lisp. I've got a routine that creates unnamed groups and I'd like to be able to move the components around so I'm starting with something like this:
Code: [Select]
(defun bunches (/ grp pt1 pt2)
  (setq pt1 (getpoint "Select a point: ")
pt2 (getpoint "Select another point: ")
)
  (command "_.circle" pt1 12.0)
  (setq grp (ssget "L"))
  (command "_.circle" pt2 12.0)
  (setq grp (ssadd (entlast) grp))
  (command "-group" "c" "*" "" grp "")
  (princ)
  )
Now the two are one, but I can't move only one. :?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Together, but apart....
« Reply #3 on: March 30, 2004, 12:18:46 AM »
You could remove grp from the declared variables making it global.
Do not use the group at all unless you need it.

Code: [Select]
(defun bunches (/  pt1 pt2)
  (setq   pt1 (getpoint "Select a point: ")
   pt2 (getpoint "Select another point: ")
   )
  (command "_.circle" pt1 12.0)
  (setq grp (ssget "L"))
  (command "_.circle" pt2 12.0)
  (setq grp (ssadd (entlast) grp))
  ;(command "-group" "c" "*" "" grp "")
  (princ)
  )


Command: _move
Select objects: !grp   <======<<<  
<Selection set: 3d>
2 found

Select objects:
Specify base point or displacement: Specify second point of displacement or
<use first point as displacement>:

Just a though..

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Water Bear

  • Guest
Together, but apart....
« Reply #4 on: March 30, 2004, 08:35:01 AM »
Quote
Command: _move
Select objects: !grp <======<<<
<Selection set: 3d>
2 found
This will still move both objects in the set :?

Columbia

  • Guest
Together, but apart....
« Reply #5 on: March 30, 2004, 10:03:04 AM »
One way you could do it instead of using groups is to create a global list of the entity names.  And then what you could do is act on the list when you want to.

Does that make any sense?

SMadsen

  • Guest
Together, but apart....
« Reply #6 on: March 30, 2004, 10:24:53 AM »
Not sure I understand this question correctly but there's only PICKSTYLE that determines the behavior of commands when dealing with groups. If correctly understood, it seems you either need to grab the issued commands with a reactor and set PICKSTYLE accordingly, or you may want to try Columbia's excellent suggestion.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Together, but apart....
« Reply #7 on: March 30, 2004, 10:39:46 AM »
Quote from: Water Bear
Quote
Command: _move
Select objects: !grp <======<<<
<Selection set: 3d>
2 found
This will still move both objects in the set :?


That is the point. If you want to move the selections set named grp enter !grp.
If you want to move anything else just do it as you would normally.

Make sense? :)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Columbia

  • Guest
Together, but apart....
« Reply #8 on: March 30, 2004, 10:57:11 AM »
Thanks, Stig!  I wasn't sure any one would understand my poorly written presentation of an obscure idea.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Together, but apart....
« Reply #9 on: March 30, 2004, 11:40:02 AM »
Quote from: Columbia
One way you could do it instead of using groups is to create a global list of the entity names.  And then what you could do is act on the list when you want to.

Does that make any sense?


Is this not a global selection set with all entities?
I don't understand what form this "global list" would take.

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Water Bear

  • Guest
Together, but apart....
« Reply #10 on: March 30, 2004, 12:15:24 PM »
@CAB I get it now.. :keb: the problem is that I was re-using that selection set name "grp" everytime I made a new section of duct. So the set wouldn't have the same name after I drew a few pieces. What if I had to move it later on? If this doesn't make sense , let me know and I'll add an image.

@Columbia could you elborate? how do I set that up to start?

Columbia

  • Guest
Together, but apart....
« Reply #11 on: March 30, 2004, 01:15:00 PM »
Okay... are we sitting down comfortably, because this could be a long one... (long sip of coffee)...here we go...

What I mean is this:  In your program you could compile together a LIST of entity names that you want to hold together and instead of using that LIST to form a GROUP, you could just keep that list separate.

Why would you want to do this???

Well, think of it this way.  If you have it in a GROUP you are stuck with some of GROUPs more limiting features.  For instance, if you want to change the layer of only one of the entities.  Using a selectable group, you end up changing all of them.

With using a stored LIST instead, you could conceivably do anything you wanted to the individual entities (move, trim, copy, extend, mirror, etc...) and then using a command that makes use of the LIST you could then manipulate all of those entities in anyway.  Of course, to do that you would have to build commands that would explicitly deal with that list.

Then again, on second thought what would probably be the most useful to you instead of a list is a global SELECTION SET.  It's used the same way, but then you wouldn't have to test to see if an entity from your list still exists before trying to perform an operation on it.

Does this clear anything up any??  Or is it still clear as mud?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Together, but apart....
« Reply #12 on: March 30, 2004, 01:16:46 PM »
I would think a global an array is needed or write the entity list to a text file?

Just speculating, cause safe arrays are not in my arsenal. :)

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Together, but apart....
« Reply #13 on: March 30, 2004, 01:31:34 PM »
Water Bear,
Here is a brief example I whiped up for you to help you with what Colombia is talking about.  

Code: [Select]
;;; A procedure for storing a variable in an association list form.
(defun var-store (var value)
  (cond ((and value) (cons var value))
        ((cons var (getvar var)))))

;;; another procedure for doing something on a whole list of stuff.
(defun Save-this-list (lst) ; <- give me a list to do stuff to.
  (mapcar                               ;;     Do this to this
                                        ;;          |      |
    '(lambda (x) (var-store (car x) (cadr x)));;<---+      |
    lst ;; <-----------------------------------------------+
    ))

;;; Fill a variable with some information to save.
(setq alist '((blipmode nil) (clayer nil) (pt1 '(6.6 2.6 0.0)))) ;; My list of info
;;; This list represents information on an entity. (location, points, etc. I just tossed some stuff
;;; in there so you can get a general idea.)
(save-this-list alist) ;; save the list of info


Now you have a nice tidy list of information saved on any given entity--or entities if you so wish.-- that you can retrieve at any given point.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Water Bear

  • Guest
Together, but apart....
« Reply #14 on: March 30, 2004, 02:15:50 PM »
@Columbia, I don't think that I can leave them as selection sets because I will be creating 300+ sets (alot of duct pieces, air outlets etc...) and as I recall, there is a limit in Autocad for selection sets.

@Seven, I see how that works well for a variable and a value...but how can I use that to associate: say, a line, an arc, a piece number (text) and a text box? I need to be able to move the piece number, if there is another duct below and it's piece number overwrites the first one; However, if I delete the piece number, I want everything associated with that number to be gone?
Also these associations must remain intact from one drawing session to the next.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Together, but apart....
« Reply #15 on: March 30, 2004, 03:12:39 PM »
Well, I know this is not what you are looking for ... exactly ... but it should work ...
Create a command reactor ....
Here is what I would use for Pseudo Code...

[code]
begin command reactor
pickstyle set to 1 or 3 by default
grab current pickstyle setting
if begin command reactor reports "move" "copy" "trim" "extend" "mirror" etc ....
set pickstyle to 0

end command reactor
if end command reactor reports "move" "copy" "trim" "extend" "mirror" etc ....
set pickstyle to 1 or 3 (or previous setting)

Quote


It is now transparent, and you do not have to be running the original lisp to handle it.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Together, but apart....
« Reply #16 on: March 30, 2004, 04:23:38 PM »
Quote from: Water Bear
@Columbia, I don't think that I can leave them as selection sets because I will be creating 300+ sets (alot of duct pieces, air outlets etc...) and as I recall, there is a limit in Autocad for selection sets.

@Seven, I see how that works well for a variable and a value...but how can I use that to associate: say, a line, an arc, a piece number (text) and a text box? I need to be able to move the piece number, if there is another duct below and it's piece number overwrites the first one; However, if I delete the piece number, I want everything associated with that number to be gone?
Also these associations must remain intact from one drawing session to the next.


(I was thinking alot smaller then what you just said.)

Water bear, you are talking about one H U G E program! (the same program that i -along with every other autocad'er-  has been "wanting" to write for along time now.) but the theory is all the same.  Your steping into the OOP world now. If you really want something like this i sudgest you design your pants off before you slap down any code. (Im not trying to discourage you in any way man! If you realy want this, go for it! but im just saying that...) you need to design the program before you go about coding ANYTHING on something as "advanced" as this.  

But;
Command: (setq ent-list-1 (cons "ent1" (car (entsel))))
Select object: ("ent1" . <Entity name: 435de70>)

Command: (setq ent-list-2 (cons "ent2" (car (entsel))))
Select object: ("ent2" . <Entity name: 435de88>)

Command: (setq master-data-list (append (list ent-list-1 ent-list-2)))
(("ent1" . <Entity name: 435de70>) ("ent2" . <Entity name: 435de88>))
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Water Bear

  • Guest
Together, but apart....
« Reply #17 on: March 30, 2004, 04:26:51 PM »
OK..it looks as though everyone agrees..reactors  it is! Now where can I get some good info  (with examples) of how to use reactors? I tried that "gardenpath" tutorial, but I got lost midway through! :horror: And the Developers help menu really just gives you alot of command lists.. :shock:
any recommended sources?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Together, but apart....
« Reply #18 on: March 30, 2004, 04:39:48 PM »
Quote from: water bear
Also these associations must remain intact from one drawing session to the next.


Seems like you are talking about "Smart Entities".
Perhaps if you used ADT or in my case ArchT and draw the duct as short fat walls.
The program take care of the overhead & you just draw the objects on plan view,
give them a size & Height and the routine cleans up the intersections.
The amount of coding behind these smart objects is many man hours so you might be
money ahead buying some specialized software.
My 2 cents.

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Water Bear

  • Guest
Together, but apart....
« Reply #19 on: March 30, 2004, 08:23:14 PM »
Actually that was what cause me to take on this project. I've worked with all the major programs and found that they were unprofessional, from the sheetmetal point of view. You see I've work in the shop, in the field and in the drafting room. I know how to design and make duct. Those other programs allow you to draw pieces that either cannot be made or are not cost-effective. I guess it is because they are written by programmers who have no experience in the field. Take a look http://theswamp.org/lilly.pond/Water%20Bear/swampthing.gif this is the first drawing I did with what I've learned at the swamp. Everything was drawn by lisp routines and  I've gotten pretty far with it. I think it might be worth completing the project. :wink:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Together, but apart....
« Reply #20 on: March 30, 2004, 09:28:56 PM »
That looks very interesting, would love to get a look at the actual drawing.

Sounds like you are committed, that's what it takes to get a big job done.
Did not realize you were well on your way with this project.

Could you explain  more about the groups. What you need to do with them?
What components make up a group. How the objects in the group are created.
What would need to be edited in the group once created? Stuff like that.

Only if you have time & the inclination should you answer my query.

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Columbia

  • Guest
Together, but apart....
« Reply #21 on: March 31, 2004, 07:56:22 AM »
Water Bear,

There is a relatively quick and easy way you could go, that doesn't involve reactors, but is more limited than reactors.

In an early post, you said that you wanted the program to delete all entities that are related to a call out, if that call out was deleted.  Well, okay here's what you could do.  You could store the entity names as XDATA embedded into the callout entites.  And then what you could do is build a command called DUCT-DELETE or something like that, which would mine the XDATA, find the entites with the enames, check for their exsistence, and delete them.  Doing it this way would save you some major headaches when it comes to creating reactors, but in the same respect allowing you to simulate the behavior in some minor ways.

You follow what I'm saying?  The list would then be part of the drawing, and not slave to the drawing session.

Although on second thought, enames might not get you there, I don't remember if they're persistent in the drawing.  But I know with 2004 and up that Handles are so that might do it...

Anyway, there ya go.   I hope this helps you along a little...

Water Bear

  • Guest
Together, but apart....
« Reply #22 on: March 31, 2004, 08:31:16 AM »
Thanks for the input guys!
I'll try that xdata angle first...gone to the books,brb :P

Water Bear

  • Guest
Together, but apart....
« Reply #23 on: March 31, 2004, 09:01:07 AM »
This sounds like what I might be looking for, except it's VBA:
Quote
This example prompts the user to select objects from the drawing. The selected objects are placed into a selection set, and the specified xdata is attached to all objects in that selection set.

Sub Ch10_AttachXDataToSelectionSetObjects()
    ' Create the selection set
    Dim sset As Object
    Set sset = ThisDrawing.SelectionSets.Add("SS1")
   
    ' Prompt the user to select objects
    sset.SelectOnScreen
   
    ' Define the xdata
    Dim appName As String, xdataStr As String
    appName = "MY_APP"
    xdataStr = "This is some xdata"
    Dim xdataType(0 To 1) As Integer
    Dim xdata(0 To 1) As Variant
   
    ' Define the values for each array
    '1001 indicates the appName
    xdataType(0) = 1001
    xdata(0) = appName
    '1000 indicates a string value
    xdataType(1) = 1000
    xdata(1) = xdataStr
   
    ' Loop through all entities in the selection
    ' set and assign the xdata to each entity
    Dim ent As Object
    For Each ent In sset
        ent.SetXData xdataType, xdata
    Next ent
End Sub

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Together, but apart....
« Reply #24 on: March 31, 2004, 09:11:31 AM »
Quote from: Columbia
... save you some major headaches when it comes to creating reactors, but in the same respect allowing you to simulate the behavior in some minor ways.


Remember it is as simple as changing the pickstyle variable, you can do it with this simple VBA reactor.

Try this VBA Paste it in the VBA ThisDrawing code window.....
Code: [Select]

Dim CPICK As Integer

Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
 CPICK = ThisDrawing.GetVariable("Pickstyle")
 If (CommandName = "MOVE")  Then
  Select Case CPICK
   Case 1
    ThisDrawing.SetVariable "Pickstyle", 0
   Case 3
    ThisDrawing.SetVariable "Pickstyle", 2
  End Select
 End If
End Sub

Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
 If (CommandName = "MOVE") Then
  ThisDrawing.SetVariable "Pickstyle", CPICK
 End If
End Sub


Quote from: Columbia
Although on second thought, enames might not get you there, I don't remember if they're persistent in the drawing.  But I know with 2004 and up that Handles are so that might do it...


Handles are persistent throughout the life of a drawing, unless you wblock the entire drawing. Handles are also reset on wblocked portions of the drawing.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Water Bear

  • Guest
Together, but apart....
« Reply #25 on: March 31, 2004, 10:31:26 AM »
Hey that works!  :shock:  thanx Keith!
Is there a command in lisp that will check the current command call?

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Together, but apart....
« Reply #26 on: March 31, 2004, 11:00:32 AM »
Quote from: Water Bear
Hey that works!  :shock:  thanx Keith!
Is there a command in lisp that will check the current command call?

Quote
Command: *Cancel*
Command: *Cancel*
Command: line
Specify first point: (getvar "cmdnames")
"LINE"
Invalid point.
Specify first point: *Cancel*
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org