Insert a round block using any quandrant

Discussion in 'AutoCAD' started by John Crocco, Jun 4, 2004.

  1. John Crocco

    John Crocco Guest

    I was wondering if there is a way to make a lisp routine to insert a round
    block (a circle with a T in it to designate a thermostat) on a wall using
    one of the 4 quadrants as a base point. I cant seem to figure any way to do
    it. I would like to insert a tstat by picking a wall with nearest, then
    maybe drag it towards the opposite side of the insert point, and then change
    the insert point. I can make 4 blocks, with each one a different insert
    point, then it can calculate the two points, first being the insert point,
    the second point would designate which direction so it can choose wich block
    to use. Actually, doesnt seem too hard after writting it, but could use
    some basic ideas. Would I use wcmatch and have a variable set to the
    direction of p1 and p2. if wcmatch = 0 then insert tstat-0, etc. Any ideas
    or help would be appreciated.
     
    John Crocco, Jun 4, 2004
    #1
  2. John Crocco

    T.Willey Guest

    I don't like having to many blocks in my drawings, so I would just make the insertion point the middle, that way when you move it it's the same amout on all sides. Then have the ability to pick a point on the wall, then one inside the room. Get the direction, then move it according to that direction and the scale of the block. I think that is the way I would do it.

    Tim
     
    T.Willey, Jun 4, 2004
    #2
  3. Create block with insertion point as center of circle (radius 0.1=TstatDist)

    (defun C:IB (/ SOM SOR P1 P2 TstatDist)
    (setq TstatDist 0.1)
    (setq SOM (getvar "OSMODE"))
    (setq SOR (getvar "ORTHOMODE"))
    (setvar "OSMODE" 512)
    (setvar "ORTHOMODE" 1)
    (if (setq P1 (getpoint "\nPick Point on Wall for Thermostat ? "))
    (progn
    (setvar "OSMODE" 0)
    (if (setq P2 (getpoint P1 "\nPick Point away from Wall ? "))
    (command "INSERT" "Tstat" (polar P1 (angle P1 P2) TstatDist) 1.0 1.0
    0)
    )
    )
    )
    (setvar "OSMODE" SOM)
    (setvar "ORTHOMODE" SOR)
    (princ)
    )
     
    Alan Henderson @ A'cad Solutions, Jun 4, 2004
    #3
  4. John Crocco

    jcallenj Guest

    I find it easier to have a single block definition with the text as a
    variable attribute that I can rotate back to zero. Then the insertions can
    be at any angle with the text still upright. And since you are writing a
    custom insertion command anyway, it could automatically upright the
    attribute before closing.
     
    jcallenj, Jun 4, 2004
    #4
  5. John Crocco

    John Crocco Guest

    good point.
     
    John Crocco, Jun 4, 2004
    #5
  6. John Crocco

    John Crocco Guest

    How could it automatically rotate the attriibute? If the single block has
    an attribute, insert it, give it a direction, and rotate as required within
    the routine. It would be best if the attribute had a default of T, but
    could be edited to be any other letter or number as well.
     
    John Crocco, Jun 4, 2004
    #6
  7. John Crocco

    T.Willey Guest

    After you insert it, use (entget (entlast)) to get the block, then you could cycle thru it to the attributes and change the rotation to 0 or a number relative to the rotation angle of the block.

    Tim
     
    T.Willey, Jun 4, 2004
    #7
  8. John Crocco

    Doug Broad Guest

    John,
    I would suggest that you have a single block with a center IP as
    the others have suggested. Insert it on the wall (I assume you are
    using parallel lines or are you using an ADT wall entity?)
    Keep the angle at 0 and determine the direction of a move
    to make it appear to sit on the wall surface. Use the angle of the
    wall/line and make the move perpendicular to the wall/line. Use
    the radius of the bubble for the move distance.

    Regards,
    Doug
     
    Doug Broad, Jun 4, 2004
    #8
  9. John Crocco

    John Crocco Guest

    yes, walls are horizontal or vertical

     
    John Crocco, Jun 4, 2004
    #9
  10. John Crocco

    Doug Broad Guest

    But they could be at any other angle right?
    Are they lines or ADT walls?

    With either, you could get the angle of the wall with
    entget methods. Then all you would need would
    be the side of the wall it needs to move toward.

    tstat <pick wall at insert point> <pick side to offset>
     
    Doug Broad, Jun 4, 2004
    #10
  11. John Crocco

    John Crocco Guest

    well, they are lines usually, but could also be entities as we use
    backgrounds from our client. However, in either case, they are on xreffed
    backgrounds. The walls could also be on an angle, had an angled one today,
    but unusual in fact.
     
    John Crocco, Jun 4, 2004
    #11
  12. John Crocco

    jcallenj Guest

    I am reminded now that actually we also use this 'zero rotation - offset
    from wall' method for stats, which makes me wonder. For other wall-mounted
    symbols with attribute designations (like lights and plumbing fixtures), we
    here use the 'attribute post-rotation' method I mentioned, so why not for
    stats? Just curious. Any thoughts? Doug?

    John, if the xref thing is giving you trouble I found a few helpful threads
    by searching google groups for "nestedcopy", including one in which Joe
    Burke was helping me with similar issues (that I still haven't quite worked
    through). Here is another rendition of Joe's code that will copy a single
    pick from any block. Take note that if the block is an xref, this actually
    puts the copy in it's xref layer <file|layer>. Also, I think it would choke
    on nested "complex" entities. I'm not sure what other potential limitations
    it has, but I've no doubt there are some.

    (defun c:CopyNested (/ pick obj)
    (setq pick (nentselp))
    (entmake (entget (car pick)))
    (setq obj (vlax-ename->vla-object (entlast)))
    (vla-transformby obj (vlax-tmatrix (caddr pick)))
    obj
    )

    James
     
    jcallenj, Jun 5, 2004
    #12
  13. John Crocco

    Doug Broad Guest

    I wrote a program that worked with a drawing full of electrical symbols
    and used two picks on the wall to establish rotation. It also has an semi-
    automatic layout mode. If any of the attributes look bad, I use another
    command or two to rotate them. One command rotates to 0 and allows
    a move of the attribute. It uses -attedit. Another scans a selection set
    and rotates all attributes to 0 direction.

    For all those blocks the insertion point is "on" the wall. So for circular
    blocks, the IP is the quadrant.

    I haven't improved the program in about 10 years. It time to add a
    height attribute to the outlets perhaps. I'd also like to have electrical
    data included so that I could just pick the blocks to be circuited and
    a program would connect the symbols with wire symbols and keep
    a tally of the current draw and link that to the panel and the home
    run.

    It would be relatively easy to test the block just inserted to see if it
    had any attributes and rotate them automatically to 0.
     
    Doug Broad, Jun 5, 2004
    #13
  14. John Crocco

    Joe Burke Guest

    James,

    I think you should toss that code. I believe it was Tony who pointed out, (entmake
    (entget... is a bad idea.

    Joe Burke
     
    Joe Burke, Jun 7, 2004
    #14
  15. Search these newsgroups for '(entmake (entget", and see
    what you come up with.

    In short, that combination does not really copy the
    source object. There are a number of aspects to the
    list returned by entget that make it incompatible
    with the list required by entmake, and to make matters
    worse, it will not copy application data attached to
    the object via its extension dictionary.

    True 'copying' can only be done using the COPY command
    or the ActiveX or ObjectARX APIs/

    --
    http://www.caddzone.com

    AutoCAD based Security Planning Solutions:
    http://www.caddzone.com/securityplanning

    AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
    http://www.acadxtabs.com
     
    Tony Tanzillo, Jun 7, 2004
    #15
  16. John Crocco

    Joe Burke Guest

    BTW James, the comments which preceded that bad idea were:

    ;; 3/16/2004
    ;; copy and highlight an object nested in a block insert
    ;; not intended for use with xref inserts
    ;; rough code for demonstration only

    Joe Burke
     
    Joe Burke, Jun 7, 2004
    #16
  17. John Crocco

    Joe Burke Guest

    Actually this is what I posted in a thread called 'Nssget' (like ACAD Trim/Extend
    commands) for Lisp?.

    ;; 3/16/2004
    ;; copy and highlight an object nested in a block insert
    ;; not intended for use with xref inserts
    ;; rough code for demonstration only
    (defun c:CopyNested ( / doc mspace ent vobj matrix copyobj )
    (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
    (setq mspace (vla-get-ModelSpace doc))
    (setq ent (nentselp "Select object nested in block: "))
    (setq vobj (vlax-ename->vla-object (car ent)))
    (setq matrix (caddr ent)) ;4x4 transformation matrix
    (setq copyobj (car (vlax-invoke doc 'copyobjects (list vobj) mspace)))
    (vla-transformby copyobj (vlax-tmatrix matrix)) ;transform copied object
    (vla-highlight copyobj :vlax-true)
    (princ)
    ) ;end

    Joe Burke
     
    Joe Burke, Jun 7, 2004
    #17
  18. John Crocco

    James Allen Guest

    Wow. Sorry Joe. Thanks Joe and Tony. Joe, I thought I had made a good
    improvement to your code... Should've known better. Oops. I included your
    name just to give credit where credit was due because what I posted
    originated from your sample code. Didn't mean to attach your name to junk
    code.

    All that being said and having learned a little more, would there still be a
    problem with using (entmake <stripped down (entget>, stripping the entget
    list down to just the basics required by entmake? Or is that still a bad
    idea?

    to self: Man, I thought we had something really good there too! :<
     
    James Allen, Jun 7, 2004
    #18
  19. John Crocco

    James Allen Guest

    Thanks for the thoughts Doug. I appreciate other's ideas on how to approach
    these things.
     
    James Allen, Jun 7, 2004
    #19
  20. John Crocco

    Joe Burke Guest

    James,

    No problem. I got a little confused, thinking what you posted here was what I posted
    in the other thread I mentioned. Until I went back and looked.

    Regarding (entmake (entget... I think Tony's advice rules. Why risk it when the
    CopyObjects method works?

    Maybe you modified what I posted because it seems less complicated? If so, I'd be
    happy to provide a more detailed description of what the original code does. If that
    would help...

    Regards
    Joe Burke
     
    Joe Burke, Jun 7, 2004
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.