Author Topic: Sometimes it works, sometimes it doesn't  (Read 2788 times)

0 Members and 1 Guest are viewing this topic.

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Sometimes it works, sometimes it doesn't
« on: November 07, 2008, 04:24:16 PM »
The code below is supposed to add a 150' diameter circle to a dynamic block (it groups the two objects) of a wireless access point.  When I use the ALL command, sometimes it works, sometimes it doesn't.  The current workaround is to copy the WAPs from the project file into a clean file and run the program and it will add the 150' diameter circles.  Then bring those back into the project file.  Can anyone shed any light on this?  I've also attached a "clean" sample drawing with the WAPs saved as 2007.


Code: [Select]
;;;=================================================================================================
;;; Function:    ADDWAPCIRCLE
;;;
;;; Description: Adds a 150' diameter circle to a selected WAP device and groups the objects
;;;=================================================================================================
(defun C:AddWapCircle ( / lista ent obj entName insPT WapGrp strKeyWord len)
   (setvar "pickstyle" 1)
   (setvar "osmode" 0)
   (setvar "cmdecho" 0)

   (initget 1 "S s A a X x")
   (setq strKeyWord (getkword "\n Single wap/All wap/eXit: "))
   (cond
      ((= strKeyWord "S")
         (while
            (setq ent (car (entsel "\n Select a WAP device...")))
            (if
               (and
                  (setq obj (vlax-ename->vla-object ent))
                  (eq "AcDbBlockReference" (vlax-get obj 'ObjectName))
               )
               (if (= -1 (vlax-get obj 'IsDynamicBlock))
                  (progn
                     (setq entName (vlax-get obj 'EffectiveName))
                     (setq insPT (vlax-safearray->list (vlax-variant-value (vla-get-InsertionPoint obj))))
                     (setq WapGrp (ssadd))
                     (cond
                        ((= entName "DB_GC_ClngWAP")
                           (ssadd ent WapGrp)
                           (command "circle" insPT "d" "75'")
                           (ssadd (entlast) WapGrp)
                           (command "-group" "c" "*" "" WapGrp "")
                           (princ "\n Cricle added...")
                        )
                        ((= entName "DB_GC_WallWAP")
                           (ssadd ent WapGrp)
                           (command "circle" insPT "d" "75'")
                           (ssadd (entlast) WapGrp)
                           (command "-group" "c" "*" "" WapGrp "")
                           (princ "\n Cricle added...")
                        )
                        ((= T)
                           (alert "Selected object is not a WAP device!")
                        )
                     )
                  )
                  (alert "Selected object is not a dynamic block!")
               )
               (alert "Selected object is not a block!")
            )
         )
      )
      ((= strKeyWord "A")
         (setq ss (ssget "X" '((0 . "INSERT"))))
         (setq len (sslength ss))
         (setq cnt 0)
         (repeat len
            (setq e (ssname ss cnt))
            (setq obj (vlax-ename->vla-object e))
            (if (= -1 (vlax-get obj 'IsDynamicBlock))
               (progn
                  (setq entName (vlax-get obj 'EffectiveName))
                  (setq insPT (vlax-safearray->list (vlax-variant-value (vla-get-InsertionPoint obj))))
                  (setq WapGrp (ssadd))
                  (cond
                     ((= entName "DB_GC_ClngWAP")
                        (ssadd e WapGrp)
                        (command "circle" insPT "d" "75'")
                        (ssadd (entlast) WapGrp)
                        (command "-group" "c" "*" "" WapGrp "")
                     )
                     ((= entName "DB_GC_WallWAP")
                        (ssadd e WapGrp)
                        (command "circle" insPT "d" "75'")
                        (ssadd (entlast) WapGrp)
                        (command "-group" "c" "*" "" WapGrp "")
                     )
                  )
                  (setq cnt (+ cnt 1))
               )
            )
         )
      )
      ((= strKeyWord "X")
         (princ "\n")
      )
   )
   (princ)
)

Thanks.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Sometimes it works, sometimes it doesn't
« Reply #1 on: November 07, 2008, 05:04:16 PM »
It seems to work here Matt. Another thought....since you are using DB's, why not add this circle to the block with a visibility state?
« Last Edit: November 07, 2008, 05:30:26 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Sometimes it works, sometimes it doesn't
« Reply #2 on: November 10, 2008, 08:13:10 AM »
Can't... When the symbols are inserted, their size is determined by the current LTscale.  So at 1/8" the circle would appear correct but at 1/4" it would 2Xs too large.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Sometimes it works, sometimes it doesn't
« Reply #3 on: November 10, 2008, 10:39:37 AM »
Can't... When the symbols are inserted, their size is determined by the current LTscale.  So at 1/8" the circle would appear correct but at 1/4" it would 2Xs too large.

Matt,

I'm not sure I follow. The circle diameter is a property that can be set regardless of the insert scale?

Ron
« Last Edit: November 10, 2008, 10:43:27 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Sometimes it works, sometimes it doesn't
« Reply #4 on: November 10, 2008, 10:46:15 AM »
The size of the WAP would vary based on the LTscale of the drawing.  The circle needs to be 150' diameter ALWAYS... regardless of the scale of the symbol itself.  That 150' is the effective range of the wireless access point.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Sometimes it works, sometimes it doesn't
« Reply #5 on: November 10, 2008, 11:18:39 AM »
I thought that is what the last picture I posted showed? Different size symbols, but a constant 150' diameter.

Anyhoo...made some mods to your code if you're interested:

1. Added undo points for the All selection
2. Entmake the circles instead of command for speed on large selections.
3. Change block name check to member since the same function was performed for both.

Code: [Select]
;;;=================================================================================================
;;; Function:    ADDWAPCIRCLE
;;;
;;; Description: Adds a 150' diameter circle to a selected WAP device and groups the objects
;;;=================================================================================================
(defun C:AddWapCircle (/ cnt ent obj ss strkeyword wapgrp addcircle)

  (defun addcircle (cen)
    (entmakex (list (cons 0 "CIRCLE")
    (cons 10 (trans cen 1 0))
    '(40 . 900)
      )
    )
  )

  (setvar "pickstyle" 1)
  (setvar "osmode" 0)
  (setvar "cmdecho" 0)
  (initget 1 "S s A a X x")
  (setq strKeyWord (getkword "\n Single wap/All wap/eXit: "))
  (cond
    ((= strKeyWord "S")
     (while
       (setq ent (car (entsel "\n Select a WAP device...")))
(if (and (setq obj (vlax-ename->vla-object ent))
(eq "AcDbBlockReference" (vlax-get obj 'ObjectName))
    )
  (if (= -1 (vlax-get obj 'IsDynamicBlock))
    (progn
      (setq WapGrp (ssadd))
      (if (member (vlax-get obj 'EffectiveName)
  '("DB_GC_ClngWAP" "DB_GC_WallWAP")
  )
(progn
  (ssadd ent WapGrp)
  (ssadd (addcircle (vlax-get obj 'InsertionPoint)) WapGrp)
  (command "-group" "c" "*" "" WapGrp "")
  (princ "\n Circle added...")
)
(alert "Selected object is not a WAP device!")
      )
    )
    (alert "Selected object is not a dynamic block!")
  )
  (alert "Selected object is not a block!")
)
     )
    )
    ((= strKeyWord "A")
     (setq ss (ssget "X" '((0 . "INSERT"))))
     (setq cnt -1)
     (command ".undo" "begin")
     (repeat (sslength ss)
       (setq ent (ssname ss (setq cnt (1+ cnt))))
       (setq obj (vlax-ename->vla-object ent))
       (if (= -1 (vlax-get obj 'IsDynamicBlock))
(progn
   (setq WapGrp (ssadd))
   (if (member (vlax-get obj 'EffectiveName)
       '("DB_GC_ClngWAP" "DB_GC_WallWAP")
       )
     (progn
       (ssadd ent WapGrp)
       (ssadd (addcircle (vlax-get obj 'InsertionPoint)) WapGrp)
       (command "-group" "c" "*" "" WapGrp "")
       (princ "\n Circle added...")
     )
   )
)
       )
     )
     (command ".undo" "end")
    )
    ((= strKeyWord "X")
     (princ "\n")
    )
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Sometimes it works, sometimes it doesn't
« Reply #6 on: November 10, 2008, 11:30:47 AM »
I thought that is what the last picture I posted showed? Different size symbols, but a constant 150' diameter.

You can do that within a DB?  'Splain how!
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Sometimes it works, sometimes it doesn't
« Reply #7 on: November 10, 2008, 11:49:26 AM »
I thought that is what the last picture I posted showed? Different size symbols, but a constant 150' diameter.

You can do that within a DB?  'Splain how!

Take a look at the waps.dwg drawing I posted earlier. I created an example block. If you have any questions, let me know:)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Sometimes it works, sometimes it doesn't
« Reply #8 on: November 10, 2008, 11:51:00 AM »
I thought that is what the last picture I posted showed? Different size symbols, but a constant 150' diameter.

You can do that within a DB?  'Splain how!

Take a look at the waps.dwg drawing I posted earlier. I redefined created an example block. If you have any questions, let me know:)

I didn't even see that.  If I have any questions I'll post back.  Thanks!
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io