Jump to content

Reversed viewports on layouts issue


Grrr

Recommended Posts

Hi guys,

I tried really hard to get this done, but I'm stuck on this last problem I can't solve:

This routine gets info from my titleblock, and creates layout for each one accordingly to the block's attribute and parameter.

 

The problem is that all my viewports are reversed to the newly created layouts, like this:

For Layouts P1 P2 P3 P4 P5 P6 Viewports are V6 V5 V4 V3 V2 V1 (see the test.dwg)

 

I need to get them like this:

Layouts P1 P2 P3 P4 P5 P6

Viewports V1 V2 V3 V4 V5 V6

 

My guess is that the problem might be somewhere from these parts of the code:

    (setq ctr 0)
...
            (vla-getboundingbox (vlax-ename->vla-object (ssname sel ctr)) 'mn 'mx)
            (setq ctr (1+ ctr))
...
  (command "_.ZOOM"
  (trans (vlax-safearray->list mn) 0 1)
  (trans (vlax-safearray->list mx) 0 1)
  )

I'm kind of newbie, so please don't laugh hard at my coding:

; BIG Credits to Lee Mac, Tharwat
; Don't laugh at my coding, I'm newbie!

;  Function should return:
;  effective block name*
;  block rotation*
;  parameter Name and Value*
;  attribute Name and Value*
;  bounding box coordinates
;  and must filter the selection by the name of the dynamic block

; This routine gets all dynamic blocks in layer "VLD_РАМКА", reads their names,rotations,attributes and parameters and creates layouts based on those

;PROBLEM: Must symmetrically reverse the boundingbox point list! Results: for Plans P1 P2 P3 P4 P5 P6 Viewports are V6 V5 V4 V3 V2 V1 (see the test.dwg)
; in other words: the viewports are reversed to the created layouts

(defun c:test ( / ent sel brot brot-val blkname paramval MyParameterName attval MyAttributeName mn mx donothing )
 (vl-load-com)
 (setq acadApp (vlax-get-Acad-object))
 (setq acadDoc (vla-get-ActiveDocument acadApp))
 (setq layouts (vla-get-Layouts acadDoc))
 (setq layoutObj (vla-get-ActiveLayout acadDoc))

   (setq ctr 0)
   (setq MyParameterName "SHEETSIZE")                                                 ;<-PARAMETER NAME (type name of the parameter here)
   (setq MyAttributeName "SHEETNAME")                                                 ;<-ATTRIBUTE NAME (type name of the attribute here)
   (prompt "\nSelect attributed dynamic blocks")

(if (setq sel (ssget "X" (list (cons 0 "INSERT")(cons 8 "VLD_РАМКА")))); filter by the type and the layer of the titleblock (since its hard to filter by its effname)
       (repeat (setq idx (sslength sel))
           (setq ent (ssname sel (setq idx (1- idx))))
            (vla-getboundingbox (vlax-ename->vla-object (ssname sel ctr)) 'mn 'mx)
            (setq ctr (1+ ctr))
           (setq blkname (LM:al-effectivename (ssname sel 0)))                        ;<-BLOCK NAME
;            (princ (strcat "\nBlockName: " blkname ))
           (if (setq brot (vla-get-rotation (vlax-ename->vla-object ent)))            ;<-BLOCK ROTATION
             (progn
               (setq brot-val (angtos brot 0 0))                                        ;rtos converts "brot" into string format, use angtos for angles
               (setq donothing 1)
             )
               (princ (strcat "\nBlockRotation not found" ))
           )
           (if (setq paramval (LM:getdynpropvalue (vlax-ename->vla-object ent) MyParameterName)) ;PARAMETER VALUE
               (setq donothing 1)
               (princ (strcat "\nParameter " MyParameterName " not found in block " blkname))
           )
           (if (setq attval (LM:getattributevalue ent MyAttributeName))                          ;ATTRIBUTE VALUE
               (setq donothing 1)
               (princ (strcat "\nAttribute " MyAttributeName " not found in block " blkname))
           )
           (princ (strcat "\nTotal results: " blkname " " brot-val " " paramval " " attval))     ;TOTAL RESULTS

;*Get the Wildcards:
;for sheetsize:
(cond
((= paramval "A4 M 1:1") (setq WC-shtsize "A4" ))
((= paramval "A4 M 1:2") (setq WC-shtsize "A4" ))
((= paramval "A4 M 1:5") (setq WC-shtsize "A4" ))
((= paramval "A4 M 1:10") (setq WC-shtsize "A4" ))
((= paramval "A4 M 1:20") (setq WC-shtsize "A4" ))
((= paramval "A4 M 1:50") (setq WC-shtsize "A4" ))
((= paramval "A4 M 1:100") (setq WC-shtsize "A4" ))
((= paramval "A4 M 1:200") (setq WC-shtsize "A4" ))
((= paramval "A4 M 1:500") (setq WC-shtsize "A4" ))
((= paramval "A4 M 1:1 000") (setq WC-shtsize "A4" ))
((= paramval "A4 M 1:2 000") (setq WC-shtsize "A4" ))
((= paramval "A4 M 1:5 000") (setq WC-shtsize "A4" ))
((= paramval "A4 M 1:10 000") (setq WC-shtsize "A4" ))

((= paramval "A3 M 1:1") (setq WC-shtsize "A3" ))
((= paramval "A3 M 1:2") (setq WC-shtsize "A3" ))
((= paramval "A3 M 1:5") (setq WC-shtsize "A3" ))
((= paramval "A3 M 1:10") (setq WC-shtsize "A3" ))
((= paramval "A3 M 1:20") (setq WC-shtsize "A3" ))
((= paramval "A3 M 1:50") (setq WC-shtsize "A3" ))
((= paramval "A3 M 1:100") (setq WC-shtsize "A3" ))
((= paramval "A3 M 1:200") (setq WC-shtsize "A3" ))
((= paramval "A3 M 1:500") (setq WC-shtsize "A3" ))
((= paramval "A3 M 1:1 000") (setq WC-shtsize "A3" ))
((= paramval "A3 M 1:2 000") (setq WC-shtsize "A3" ))
((= paramval "A3 M 1:5 000") (setq WC-shtsize "A3" ))
((= paramval "A3 M 1:10 000") (setq WC-shtsize "A3" ))

((= paramval "A2 M 1:1") (setq WC-shtsize "A2" ))
((= paramval "A2 M 1:2") (setq WC-shtsize "A2" ))
((= paramval "A2 M 1:5") (setq WC-shtsize "A2" ))
((= paramval "A2 M 1:10") (setq WC-shtsize "A2" ))
((= paramval "A2 M 1:20") (setq WC-shtsize "A2" ))
((= paramval "A2 M 1:50") (setq WC-shtsize "A2" ))
((= paramval "A2 M 1:100") (setq WC-shtsize "A2" ))
((= paramval "A2 M 1:200") (setq WC-shtsize "A2" ))
((= paramval "A2 M 1:500") (setq WC-shtsize "A2" ))
((= paramval "A2 M 1:1 000") (setq WC-shtsize "A2" ))
((= paramval "A2 M 1:2 000") (setq WC-shtsize "A2" ))
((= paramval "A2 M 1:5 000") (setq WC-shtsize "A2" ))
((= paramval "A2 M 1:10 000") (setq WC-shtsize "A2" ))

((= paramval "A1 M 1:1") (setq WC-shtsize "A1" ))
((= paramval "A1 M 1:2") (setq WC-shtsize "A1" ))
((= paramval "A1 M 1:5") (setq WC-shtsize "A1" ))
((= paramval "A1 M 1:10") (setq WC-shtsize "A1" ))
((= paramval "A1 M 1:20") (setq WC-shtsize "A1" ))
((= paramval "A1 M 1:50") (setq WC-shtsize "A1" ))
((= paramval "A1 M 1:100") (setq WC-shtsize "A1" ))
((= paramval "A1 M 1:200") (setq WC-shtsize "A1" ))
((= paramval "A1 M 1:500") (setq WC-shtsize "A1" ))
((= paramval "A1 M 1:1 000") (setq WC-shtsize "A1" ))
((= paramval "A1 M 1:2 000") (setq WC-shtsize "A1" ))
((= paramval "A1 M 1:5 000") (setq WC-shtsize "A1" ))
((= paramval "A1 M 1:10 000") (setq WC-shtsize "A1" ))

((= paramval "A0 M 1:1") (setq WC-shtsize "A0" ))
((= paramval "A0 M 1:2") (setq WC-shtsize "A0" ))
((= paramval "A0 M 1:5") (setq WC-shtsize "A0" ))
((= paramval "A0 M 1:10") (setq WC-shtsize "A0" ))
((= paramval "A0 M 1:20") (setq WC-shtsize "A0" ))
((= paramval "A0 M 1:50") (setq WC-shtsize "A0" ))
((= paramval "A0 M 1:100") (setq WC-shtsize "A0" ))
((= paramval "A0 M 1:200") (setq WC-shtsize "A0" ))
((= paramval "A0 M 1:500") (setq WC-shtsize "A0" ))
((= paramval "A0 M 1:1 000") (setq WC-shtsize "A0" ))
((= paramval "A0 M 1:2 000") (setq WC-shtsize "A0" ))
((= paramval "A0 M 1:5 000") (setq WC-shtsize "A0" ))
((= paramval "A0 M 1:10 000") (setq WC-shtsize "A0" ))

);cond


;for orientation:
(cond
((= brot-val "0") (setq WC-orient "L" ))
((= brot-val "180") (setq WC-orient "L" ))
((= brot-val "360") (setq WC-orient "L" ))
((= brot-val "90") (setq WC-orient "P" ))
((= brot-val "270") (setq WC-orient "P" ))
((not (eq brot-val "0,90,180,270,360")) (setq WC-shtsize "N" ))
);cond

(setq TOTALNAME (strcat WC-shtsize "-" WC-orient "_" ATTVAL))



;*Delete the layout, named TOTALNAME if it exists:
 (vlax-for objLayout layouts
   (if (= (vla-get-name objLayout) TOTALNAME)
     (progn
       (princ
         (strcat "\nDeleted Layout named "
             (vla-get-name objLayout) "..."
         )
       )
       (vla-delete objLayout) ;delete the Layout
       (vlax-release-object objLayout) ; release the Layout Object
     );progn
   );if
 ) ;vlax-for

;*Create the new layout, named TOTALNAME: 
 (setq layoutObj (vla-add layouts TOTALNAME))

;*Assign BLACK-GRAY-WHITE.CTB to the Layout:
 (vla-put-StyleSheet layoutObj "BLACK-GRAY-WHITE.CTB")

;*Assign DWF configuration to the Layout:
 (if (= (substr (vlax-variant-value (vla-getvariable acadDoc "ACADVER")) 1 2) "15")
   (vla-put-configname layoutObj "PublishToWeb DWF.pc3")
   (vla-put-configname layoutObj "DWG To PDF.pc3")
 ) ;if

;*Assign predefined SHEETSIZE to the Layout: 

(cond
((= paramval "A4 M 1:1") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A4_(297.00_x_210.00_MM)" ))
((= paramval "A4 M 1:2") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A4_(297.00_x_210.00_MM)" ))
((= paramval "A4 M 1:5") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A4_(297.00_x_210.00_MM)" ))
((= paramval "A4 M 1:10") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A4_(297.00_x_210.00_MM)" ))
((= paramval "A4 M 1:20") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A4_(297.00_x_210.00_MM)" ))
((= paramval "A4 M 1:50") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A4_(297.00_x_210.00_MM)" ))
((= paramval "A4 M 1:100") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A4_(297.00_x_210.00_MM)" ))
((= paramval "A4 M 1:200") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A4_(297.00_x_210.00_MM)" ))
((= paramval "A4 M 1:500") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A4_(297.00_x_210.00_MM)" ))
((= paramval "A4 M 1:1 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A4_(297.00_x_210.00_MM)" ))
((= paramval "A4 M 1:2 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A4_(297.00_x_210.00_MM)" ))
((= paramval "A4 M 1:5 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A4_(297.00_x_210.00_MM)" ))
((= paramval "A4 M 1:10 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A4_(297.00_x_210.00_MM)" ))

((= paramval "A3 M 1:1") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A3_(420.00_x_297.00_MM)" ))
((= paramval "A3 M 1:2") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A3_(420.00_x_297.00_MM)" ))
((= paramval "A3 M 1:5") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A3_(420.00_x_297.00_MM)" ))
((= paramval "A3 M 1:10") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A3_(420.00_x_297.00_MM)" ))
((= paramval "A3 M 1:20") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A3_(420.00_x_297.00_MM)" ))
((= paramval "A3 M 1:50") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A3_(420.00_x_297.00_MM)" ))
((= paramval "A3 M 1:100") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A3_(420.00_x_297.00_MM)" ))
((= paramval "A3 M 1:200") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A3_(420.00_x_297.00_MM)" ))
((= paramval "A3 M 1:500") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A3_(420.00_x_297.00_MM)" ))
((= paramval "A3 M 1:1 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A3_(420.00_x_297.00_MM)" ))
((= paramval "A3 M 1:2 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A3_(420.00_x_297.00_MM)" ))
((= paramval "A3 M 1:5 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A3_(420.00_x_297.00_MM)" ))
((= paramval "A3 M 1:10 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A3_(420.00_x_297.00_MM)" ))

((= paramval "A2 M 1:1") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A2_(594.00_x_420.00_MM)" ))
((= paramval "A2 M 1:2") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A2_(594.00_x_420.00_MM)" ))
((= paramval "A2 M 1:5") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A2_(594.00_x_420.00_MM)" ))
((= paramval "A2 M 1:10") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A2_(594.00_x_420.00_MM)" ))
((= paramval "A2 M 1:20") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A2_(594.00_x_420.00_MM)" ))
((= paramval "A2 M 1:50") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A2_(594.00_x_420.00_MM)" ))
((= paramval "A2 M 1:100") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A2_(594.00_x_420.00_MM)" ))
((= paramval "A2 M 1:200") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A2_(594.00_x_420.00_MM)" ))
((= paramval "A2 M 1:500") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A2_(594.00_x_420.00_MM)" ))
((= paramval "A2 M 1:1 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A2_(594.00_x_420.00_MM)" ))
((= paramval "A2 M 1:2 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A2_(594.00_x_420.00_MM)" ))
((= paramval "A2 M 1:5 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A2_(594.00_x_420.00_MM)" ))
((= paramval "A2 M 1:10 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A2_(594.00_x_420.00_MM)" ))

((= paramval "A1 M 1:1") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A1_(841.00_x_594.00_MM)" ))
((= paramval "A1 M 1:2") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A1_(841.00_x_594.00_MM)" ))
((= paramval "A1 M 1:5") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A1_(841.00_x_594.00_MM)" ))
((= paramval "A1 M 1:10") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A1_(841.00_x_594.00_MM)" ))
((= paramval "A1 M 1:20") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A1_(841.00_x_594.00_MM)" ))
((= paramval "A1 M 1:50") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A1_(841.00_x_594.00_MM)" ))
((= paramval "A1 M 1:100") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A1_(841.00_x_594.00_MM)" ))
((= paramval "A1 M 1:200") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A1_(841.00_x_594.00_MM)" ))
((= paramval "A1 M 1:500") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A1_(841.00_x_594.00_MM)" ))
((= paramval "A1 M 1:1 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A1_(841.00_x_594.00_MM)" ))
((= paramval "A1 M 1:2 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A1_(841.00_x_594.00_MM)" ))
((= paramval "A1 M 1:5 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A1_(841.00_x_594.00_MM)" ))
((= paramval "A1 M 1:10 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A1_(841.00_x_594.00_MM)" ))

((= paramval "A0 M 1:1") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A0_(841.00_x_1189.00_MM)" ))
((= paramval "A0 M 1:2") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A0_(841.00_x_1189.00_MM)" ))
((= paramval "A0 M 1:5") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A0_(841.00_x_1189.00_MM)" ))
((= paramval "A0 M 1:10") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A0_(841.00_x_1189.00_MM)" ))
((= paramval "A0 M 1:20") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A0_(841.00_x_1189.00_MM)" ))
((= paramval "A0 M 1:50") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A0_(841.00_x_1189.00_MM)" ))
((= paramval "A0 M 1:100") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A0_(841.00_x_1189.00_MM)" ))
((= paramval "A0 M 1:200") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A0_(841.00_x_1189.00_MM)" ))
((= paramval "A0 M 1:500") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A0_(841.00_x_1189.00_MM)" ))
((= paramval "A0 M 1:1 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A0_(841.00_x_1189.00_MM)" ))
((= paramval "A0 M 1:2 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A0_(841.00_x_1189.00_MM)" ))
((= paramval "A0 M 1:5 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A0_(841.00_x_1189.00_MM)" ))
((= paramval "A0 M 1:10 000") (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A0_(841.00_x_1189.00_MM)" ))

);cond

;*Make the new Layout Active:
 (vla-put-activelayout acadDoc layoutObj) 

;*Set the Layout orientation:
; is it possible ???(vla-put-PlotRotation layoutObj brot)???

 (cond
 ((= brot-val "0") (vla-put-PlotRotation layoutObj ac0degrees))
 ((= brot-val "180") (vla-put-PlotRotation layoutObj ac0degrees))
 ((= brot-val "360") (vla-put-PlotRotation layoutObj ac0degrees))
 ((= brot-val "90") (vla-put-PlotRotation layoutObj ac90degrees))
 ((= brot-val "270") (vla-put-PlotRotation layoutObj ac90degrees))
 ((not (eq brot-val "0,90,180,270,360")) (princ (strcat "\nBlock rotation is not supported for the layout " attval)))
 );cond

;*Deletes the initial viewport, from the created layout:
  (setq ssVP
  (ssget "_X"
  (list '(0 . "VIEWPORT") (cons 410 (getvar 'ctab)))
  )
  )
  (command "erase" ssVP "")

;*Creates new viewport, for the layout:
  (COMMAND "_.VPORTS" "FIT")
  (COMMAND "_.MSPACE")
  (command "_.ZOOM"
  (trans (vlax-safearray->list mn) 0 1)
  (trans (vlax-safearray->list mx) 0 1)
  )
  (COMMAND "_.PSPACE")

; Assign correct scale to the viewports, created with "FIT" option:

  (setq ssVP (ssget "x" '((0 . "viewport") (-4 . ">") (69 . 1)))
  )
  (setq curScale (vla-get-CustomScale (vlax-ename->vla-object (ssname ssVP 0)))
  ) ;setq

(setq newScale (vla-put-customscale (vlax-ename->vla-object (ssname ssVP 0))
              (cond
                  (   (<= 0.95     curScale) 1      ) ;fix for scale minval 1:1 
                  (   (<= 0.495    curScale) 0.5    ) ;fix for scale minval 1:2 
                  (   (<= 0.195    curScale) 0.2    ) ;fix for scale minval 1:5 
                  (   (<= 0.095    curScale) 0.1    ) ;fix for scale minval 1:10
                  (   (<= 0.0495   curScale) 0.05   ) ;fix for scale minval 1:20
                  (   (<= 0.0195   curScale) 0.02   ) ;fix for scale minval 1:50
                  (   (<= 0.0095   curScale) 0.01   ) ;fix for scale minval 1:100
                  (   (<= 0.00495  curScale) 0.005  ) ;fix for scale minval 1:200
                  (   (<= 0.00195  curScale) 0.002  ) ;fix for scale minval 1:500
                  (   (<= 0.00095  curScale) 0.001  ) ;fix for scale minval 1:1 000
                  (   (<= 0.000495 curScale) 0.0005 ) ;fix for scale minval 1:2 000
                  (   (<= 0.000195 curScale) 0.0002 ) ;fix for scale minval 1:5 000
                  (   (<= 0.000095 curScale) 0.0001 ) ;fix for scale minval 1:10 000
                  (   curScale   )
              )
          )
);setq





;;;*Delete the default Layout1 and Layout2 if they exist, after my 1st custom layout is created:
 (vlax-for objLayout layouts
   (if (= (vla-get-name objLayout) "Layout1")
     (progn
       (vla-delete objLayout) ;delete the Layout
       (vlax-release-object objLayout) ; release the Layout Object
     );progn
   );if
 ) ;vlax-for
 (vlax-for objLayout layouts
   (if (= (vla-get-name objLayout) "Layout2")
     (progn
       (vla-delete objLayout) ;delete the Layout
       (vlax-release-object objLayout) ; release the Layout Object
     );progn
   );if
 ) ;vlax-for
;;;

 (setvar "ctab" "model")
  (princ (strcat "\nCreated layout: " ATTVAL ))
       ); end of repeat
;   (COMMAND "_.CTAB" "MODEL")
   )
   (princ)
)

;; Get Dynamic Block Property Value  -  Lee Mac
;; Returns the value of a Dynamic Block property (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; prp - [str] Dynamic Block property name (case-insensitive)

(defun LM:getdynpropvalue ( blk prp )
   (setq prp (strcase prp))
   (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value)))
       (vlax-invoke blk 'getdynamicblockproperties)
   )
)


;; Get Attribute Value  -  Lee Mac
;; Returns the value held by the specified tag within the supplied block, if present.
;; blk - [vla] VLA Block Reference Object
;; tag - [str] Attribute TagString
;; Returns: [str] Attribute value, else nil if tag is not found.

(defun LM:getattributevalue ( blk tag / enx )
   (if (= "ATTRIB" (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk)))))))
       (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
           (cdr (assoc 1 enx))
           (LM:getattributevalue blk tag)
       )
   )
)


;; Effective Block Name  -  Lee Mac
;; ent - [ent] Block Reference entity

(defun LM:al-effectivename ( ent / blk rep )
   (if (wcmatch (setq blk (cdr (assoc 2 (entget ent)))) "`**")
       (if
           (and
               (setq rep
                   (cdadr
                       (assoc -3
                           (entget
                               (cdr
                                   (assoc 330
                                       (entget
                                           (tblobjname "block" blk)
                                       )
                                   )
                               )
                              '("AcDbBlockRepBTag")
                           )
                       )
                   )
               )
               (setq rep (handent (cdr (assoc 1005 rep))))
           )
           (setq blk (cdr (assoc 2 (entget rep))))
       )
   )
   blk
)

 

Attached the lisp file and the dwg :)

test.lsp

test.dwg

Link to comment
Share on other sites

BIGAL,

Tried that it didn't work, maybe to reverse the "mn" and "mx" list ? But I don't know how.

EDIT: maybe somehow to construct a list with vla-getboundingox and reverse it?

EDIT2: well yeah, fixed it by myself

 

instead of:

   (command "_.ZOOM"
  (trans (vlax-safearray->list mn) 0 1)
  (trans (vlax-safearray->list mx) 0 1)
  )

I used:

   (command "_.ZOOM" "object" ent "")

Edited by Grrr
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...