Author Topic: Block walk, help needed in testing  (Read 7285 times)

0 Members and 1 Guest are viewing this topic.

kevinpo

  • Guest
Re: Block walk, help needed in testing
« Reply #15 on: September 24, 2009, 11:17:57 AM »
I took your advise and went ahead and came up with an OpenDCL version.

However I had to make the local functions global and had to rename the *error* function to another name so it could be executed after hitting the Close button.

The only thing I can't figure out now is when you hit escape to get out of it I can't get the visibility for everything to come back.

Maybe you guys could figure it out.

I have attached a ZIP file with everything needed to make it run. No need to install anything else.
Just unzip into folder and add path.

Kevin


kevinpo

  • Guest
Re: Block walk, help needed in testing
« Reply #16 on: September 24, 2009, 11:22:18 AM »
Sorry, new to this..
the OpenDCL version uses a modeless dialog which lets you pan and zoom around to look a the blocks.

Also, type BW to run.


Kevin

kevinpo

  • Guest
Re: Block walk, help needed in testing
« Reply #17 on: September 24, 2009, 11:40:33 AM »
Just thought of something else, Not sure if it's possible.

What about locking the layers and having the Fade set at 80% (real dark) and showing the blocks?
This would give you the visual reference for showing the blocks.

Not sure this could be done because you're changing the visibility of the entities and not the layer and for the fact that other objects can exist on the same layer as the block.
Hmmm??

Could this be done?

Kevin

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Block walk, help needed in testing
« Reply #18 on: September 24, 2009, 11:46:54 AM »
Just thought of something else, Not sure if it's possible.

What about locking the layers and having the Fade set at 80% (real dark) and showing the blocks?
This would give you the visual reference for showing the blocks.

Not sure this could be done because you're changing the visibility of the entities and not the layer and for the fact that other objects can exist on the same layer as the block.
Hmmm??

Could this be done?

Kevin

The new version that I'm working on was going to use layers, so that may be possible with that one, but with that I couldn't get it to work with xrefs, so that ability may be lost.  I'm still coding, but when it's ready enough to post I will.  Then we can see about the shading of locked layers fading to the back.

I don't use ODCL, but I would assume that there is an on exit/close, or something like that, so I would put the code there to show everything again.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

kevinpo

  • Guest
Re: Block walk, help needed in testing
« Reply #19 on: September 24, 2009, 12:10:03 PM »
Perhaps making the blocks Blink.

K

Crank

  • Water Moccasin
  • Posts: 1503
Re: Block walk, help needed in testing
« Reply #20 on: September 24, 2009, 12:46:52 PM »
Just thought of something else, Not sure if it's possible.

What about locking the layers and having the Fade set at 80% (real dark) and showing the blocks?
This would give you the visual reference for showing the blocks.

Not sure this could be done because you're changing the visibility of the entities and not the layer and for the fact that other objects can exist on the same layer as the block.
Hmmm??

Could this be done?

Kevin

Not with layers, but you could use refedit/refclose for this.
Vault Professional 2023     +     AEC Collection

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Block walk, help needed in testing
« Reply #21 on: September 24, 2009, 02:09:08 PM »
Well I think this idea is a bust.  It will not work with Dynamic block.  I tested in '06 and '09.  It will redefine each dynamic block definition again.  So lets say you have one dy block, dyblock.  It has a couple of visibility states, and when you change the state it creates an anonymous definition per state.  So you copy that three times, so there is now two blocks, dyblock & *U1.  After you run the code you will have four block definition, dyblock, *U1, *U2 & *U3.  Not cool.  At least with only changing the layer, they still look correct, but they still get renamed, so you don't really get a true representation of the block being isolated.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Block walk, help needed in testing
« Reply #22 on: September 24, 2009, 02:12:46 PM »
Just in case someone wants the code for isolating by layer instead of object.  Same dialog as before.

Code: [Select]
(defun c:BlockWalk (/ *error* GetLayInfo SelectBlock UpdateDrawing OldNum cLay ActDoc LayList tempList BlkList VisList )
   
    (defun *error* (msg)
       
        (foreach i VisList
            (if (vlax-erased-p (car i))
                (print i)
                (vla-put-Layer (car i) (cdr i))
            )
        )
        (foreach i LayList
            (vla-put-LayerOn (car i) (cadr i))
            (if (/= (vla-get-Name (car i)) cLay)
                (vla-put-Freeze (car i) (caddr i))
            )
            (vla-put-Lock (car i) (cadddr i))
        )
        (if OffLayName
            (vla-Delete (vla-Item (vla-get-Layers ActDoc) OffLayName))
        )
        (if OnLayName
            (vla-Delete (vla-Item (vla-get-Layers ActDoc) OnLayName))
        )
        (if msg (vl-bt))
        (vla-Regen ActDoc acAllViewports)
    )
    ;---------------------------------------------
    (defun GetLayInfo ( doc / ObjList )
       
        (vlax-for obj (vla-get-Layers doc)
            (setq ObjList
                (cons
                    (list
                        obj
                        (vla-get-LayerOn obj)
                        (vla-get-Freeze obj)
                        (vla-get-Lock obj)
                    )
                    ObjList
                )
            )
            (vla-put-LayerOn obj :vlax-false)
            (if (/= (vla-get-Name obj) cLay)
                (vla-put-Freeze obj :vlax-false)
            )
            (vla-put-Lock obj :vlax-false)
        )
        ObjList
    )
    ;-----------------------------------------------------------------------
    (defun SelectBlock ( Listof  / DiaLoad )
       
        (setq DiaLoad (load_dialog "MyDialogs.dcl"))
        (if (new_dialog "MyPropsList" DiaLOad)
            (progn
                (start_list "PropsListbox2" 3)
                (mapcar 'add_list Listof)
                (end_list)
                (action_tile "PropsListbox2"
                    "(if (= $reason 1)
                        (progn
                            (mode_tile \"PropsListbox2\" 1)
                            (UpdateDrawing (atoi (get_tile \"PropsListbox2\")))
                            (mode_tile \"PropsListbox2\" 0)
                            (mode_tile \"PropsListbox2\" 2)
                        )
                    )"
                )     
                (action_tile "cancel" "(done_dialog 0)")
                (start_dialog)
            )
        )
    )
    ;-------------------------------------------------------------
    (defun UpdateDrawing ( num )
        (if OldNum
            (foreach i (cdr (nth OldNum BlkList))
                (vla-put-Layer i OffLayName)
            )
        )
        (foreach i (cdr (nth num BlkList))
            (vla-put-Layer i OnLayName)
        )
        (setq OldNum num)
        (vla-Regen ActDoc acAllViewports)
    )
    ;------------------------------------------------------------------------
    (defun MyGetXData (Obj DataName / CodeType DataType)
        ; Retrive XData for an object
       
        (vla-GetXData
            Obj
            (if DataName
                DataName
                ""
            )
            'CodeType
            'DataType
        )
        (if (and CodeType DataType)
            (mapcar
                '(lambda (a b)
                    (cons a (variant-value b))
                )
                (safearray-value CodeType)
                (safearray-value DataType)
            )
        )
    )
    ;------------------------------------------------------------------------
    (setq cLay (getvar 'CLayer))
    (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
    (setq LayList (GetLayInfo ActDoc))
    (setq OffLayName "BlockWalk-templayer-Off")
    (setq OffLayer (vla-Add (vla-get-Layers ActDoc) OffLayName))
    (vla-put-LayerOn OffLayer :vlax-false)
    (setq OnLayName "BlockWalk-templayer-On")
    (setq OnLayer (vla-Add (vla-get-Layers ActDoc) OnLayName))
    (vlax-for obj (vla-get-Blocks ActDoc)
        (if
            (and
                (equal (vla-get-IsLayout obj) :vlax-false)
                (equal (vla-get-IsXref obj) :vlax-false)
                (not (wcmatch (vla-get-Name obj) "`*D*,*|*"))
            )
            (progn
                (setq tempList nil)
                (setq tempBlkList
                    (cons
                        (if (setq XdataInfo (MyGetXData obj "AcDbBlockRepBTag"))
                            (strcat (vla-get-Name (vla-HandleToObject ActDoc (cdr (assoc 1005 XdataInfo)))) "_-_( " (vla-get-Name obj) " )")
                            (vla-get-Name obj)
                        )
                        (vlax-for i obj
                            (setq VisList (cons (cons i (vla-get-Layer i)) VisList))
                            (vla-put-Layer i "0")
                            (setq tempList (cons i tempList))
                        )
                    )
                )
                (if (setq tempList (assoc (car tempBlkList) BlkList))
                    (setq BlkList (subst (append tempList (cdr tempBlkList)) tempList BlkList))
                    (setq BlkList (cons tempBlkList BlkList))
                )
            )
        )
    )
    (setq BlkList
        (vl-sort
            BlkList
            (function
                (lambda ( a b )
                    (< (car a) (car b))
                )
            )
        )
    )
    (vla-Regen ActDoc acAllViewports)
    (SelectBlock (mapcar (function car) BlkList))
    (*error* nil)
    (princ)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Marco Jacinto

  • Newt
  • Posts: 47
Re: Block walk, help needed in testing
« Reply #23 on: September 24, 2009, 05:39:21 PM »
T. Willey why instead of turning off the objects inside the blockdef, try turning off the references, with this, I think the problem with the DynBLocks won't arise, won't be as fast as the one you have, but will work.

Something like this:

Code: [Select]
(Defun c:IsoBk (/ ActDoc bk BkName)
  (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  (setq bk (vlax-ename->vla-object
     (car (entsel "\n Select block to Isolate: "))
   )
  )
  (setq BkName (vla-get-EffectiveName bk))
  (vlax-for obj (vla-get-ModelSpace actDoc)
    (if (and (vlax-property-available-p obj 'EffectiveName)
     (= (vla-get-EffectiveName obj) BkName)
)
      (vla-put-Visible obj :vlax-true)
      (vla-put-Visible obj :vlax-false)
    )
  )
  (princ)
)

Saludos

Marco Jacinto

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Block walk, help needed in testing
« Reply #24 on: September 24, 2009, 06:23:24 PM »
Marco,

  That way you won't see any nested blocks.  I think I have the answer, but the code is a lot slower because of it.  If someone can figure out a quick way to regen all the layouts, without using the Regen method, then the problem is solved.  I did a couple of quick codes, and this seems to be the issue.  I did one just like you did Marco, and it didn't error.  I'll post the new one soon, but I will need help on speeding up the regen portion of the code.

Here is the quick test of your idea I used.
Code: [Select]
(defun c:Test (/ tempName InsList VisList OldNum)
   
    (defun SelectBlock ( Listof  / DiaLoad )
       
        (setq DiaLoad (load_dialog "MyDialogs.dcl"))
        (if (new_dialog "MyPropsList" DiaLOad)
            (progn
                (start_list "PropsListbox2" 3)
                (mapcar 'add_list Listof)
                (end_list)
                (action_tile "PropsListbox2"
                    "(if (= $reason 1)
                        (progn
                            (mode_tile \"PropsListbox2\" 1)
                            (UpdateDrawing (atoi (get_tile \"PropsListbox2\")))
                            (mode_tile \"PropsListbox2\" 0)
                            (mode_tile \"PropsListbox2\" 2)
                        )
                    )"
                )     
                (action_tile "cancel" "(done_dialog 0)")
                (start_dialog)
            )
        )
    )
    ;-------------------------------------------------------------
    (defun UpdateDrawing ( num )
        (if OldNum
            (foreach i (cdr (nth OldNum InsList))
                (vla-put-Visible i :vlax-false)
                (vla-Update i)
            )
        )
        (foreach i (cdr (nth num InsList))
            (vla-put-Visible i :vlax-true)
            (vla-Update i)
        )
        (setq OldNum num)
        ;(vla-Regen (vla-get-ActiveDocument (vlax-get-Acad-Object)) acAllViewports)
    )
    ;------------------------------------------------------------------------
    (vlax-for lo (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-Acad-Object)))
        (vlax-for obj (vla-get-Block lo)
            (setq VisList (cons (cons obj (vla-get-Visible obj)) VisList))
            (vla-put-Visible obj :vlax-false)
            (vla-Update obj)
            (if (= (vla-get-ObjectName obj) "AcDbBlockReference")
                (progn
                    (setq tempName
                        (if (= (vla-get-EffectiveName obj) (vla-get-Name obj))
                            (vla-get-Name obj)
                            (strcat (vla-get-EffectiveName obj) " _-_ ( " (vla-get-Name obj) " )")
                        )
                    )
                    (setq InsList
                        (if (setq tempList (assoc tempName InsList))
                            (subst (cons tempName (cons obj (cdr tempList))) tempList InsList)
                            (cons (list tempName obj) InsList)
                        )
                    )
                )
            )
        )
    )
    (SelectBlock (mapcar (function car) InsList))
    (foreach i VisList (vla-put-Visible (car i) (cdr i)))
    (princ)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Block walk, help needed in testing
« Reply #25 on: September 25, 2009, 02:04:02 PM »
Updated code in the first post.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

kevinpo

  • Guest
Re: Block walk, help needed in testing
« Reply #26 on: September 25, 2009, 03:48:55 PM »
For some reason the dialog doesn't come up on the latest code and you were right it got a lot slower.

I'm thinking about making one for viewing entities with Xdata attached to them and show the regapp name in the dialog.

Kevin

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Block walk, help needed in testing
« Reply #27 on: September 25, 2009, 03:51:57 PM »
I didn't change any of the dialog code, so that shouldn't happen.  Is the dialog file in the search path?  Can't really think of any other reason why that would happen.  I'm thinking of doing it in C#.  I haven't done anything in awhile, and I think it could be good, and a good exercise.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.