Author Topic: match properties for blocks  (Read 12529 times)

0 Members and 1 Guest are viewing this topic.

stsevedallas

  • Guest
match properties for blocks
« on: April 17, 2006, 02:44:09 PM »
I need a lisp or lisps to match properties for blocks.
When I select a "source block", I will select multiple destination
blocks to match scale, colors, linetype, rotation, text style,
etc...everything.
Thanks


Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
Re: match properties for blocks
« Reply #1 on: April 17, 2006, 04:29:36 PM »
Code: [Select]
(if (setq SrcBlk (car (ensel "\nSelect source block: ")))
 (setq SrcLst (entget SrcBlk)
       SelSet (ssget "X" (list
                          (assoc 41 SrcLst) ;X-scale
                          (assoc 42 SrcLst) ;Y-Scale
                          (assoc 43 SrcLst) ;Z-scale
                          (assoc 50 SrcLst) ;Rotation
                          (assoc 62 SrcLst) ;Optional color
                          (assoc 6 SrcLst)  ;Optional linetype
                         )
              )
 )
)
All other properties are not block specific...
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

stsevedallas

  • Guest
Re: match properties for blocks
« Reply #2 on: April 17, 2006, 05:14:08 PM »
I tried that code and it come back and says...
"no function definition: ENSEL"
It basically did not run.

Aside from that, I need it to keep allowing me to select destination blocks until finished (or cancelled like match properties)

Thank you for the reply.

GDF

  • Water Moccasin
  • Posts: 2081
Re: match properties for blocks
« Reply #3 on: April 17, 2006, 05:29:41 PM »
I tried that code and it come back and says...
"no function definition: ENSEL"
It basically did not run.

Aside from that, I need it to keep allowing me to select destination blocks until finished (or cancelled like match properties)

Thank you for the reply.

typo, change ensel to entsel

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: match properties for blocks
« Reply #4 on: April 17, 2006, 07:45:29 PM »
I tried that code and it come back and says...
"no function definition: ENSEL"
It basically did not run.

Hint:
C:\< AutoCAD installation >\Help\acad_dev.chm
TheSwamp.org  (serving the CAD community since 2003)

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
Re: match properties for blocks
« Reply #5 on: April 18, 2006, 02:53:57 AM »
typo, change ensel to entsel
Hint:
C:\< AutoCAD installation >\Help\acad_dev.chm
Thanks guys, I shouldn't write answers late in the night of a holiday... :ugly:
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

stsevedallas

  • Guest
Re: match properties for blocks
« Reply #6 on: April 18, 2006, 08:46:44 AM »
"entsel" took care of that, however...
I now get this error,
"Error: bad SSGET list"

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: match properties for blocks
« Reply #7 on: April 18, 2006, 08:50:12 AM »
May need a vl-remove nil  ??
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.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: match properties for blocks
« Reply #8 on: April 18, 2006, 09:03:02 AM »
Methinks the intent of this posters question was missed ... it appears as though the lisp posted will simply select all of the blocks with the same properties as the one selected. What I presume the user wants is something a little more .. such as "select a block" then select other blocks to match to the original selected block .. i.e. if the original block has a scale of 2 and the selected block has a scale of 5, it will be modified to 2.
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

stsevedallas

  • Guest
Re: match properties for blocks
« Reply #9 on: April 18, 2006, 09:10:31 AM »
You are correct Keith.

"May need a vl-remove nil ??"
What is that?

Forgive my ignorance all.
Let me review the premise for this routine, just to make certain it is understood:
1. select a "source" block
2. select a destination block to match scale, rotation, color,linetype,etc. layer too.
3. keep selecting destination blocks until finished (not all blocks, just a few select ones)
note:would work like [match properties] does.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: match properties for blocks
« Reply #10 on: April 18, 2006, 10:00:33 AM »
I see, something like this?
Code: [Select]
;;  Match Block
;;  Matches properties from doner block to selected blocks
(defun c:matchblock (/ srcblk ensel srcobj prop blkobj blk color linetype
                     rotation x-scale y-scale z-scale
                    )

  (if (setq srcblk (car (entsel "\nSelect source block: ")))
    (setq srcobj   (vlax-ename->vla-object srcblk)
          x-scale  (vla-get-xscalefactor srcobj)
          y-scale  (vla-get-yscalefactor srcobj)
          z-scale  (vla-get-zscalefactor srcobj)
          rotation (vla-get-rotation srcobj)
          color    (vla-get-color srcobj)
          linetype (vla-get-linetype srcobj)

    )
  )

  (while (progn
           (prompt "\nSelect Block to update: ")
           (setq blk (ssget "+.:E:S"))
         )
    (setq blkobj (vlax-ename->vla-object (ssname blk 0)))

    (prompt "\***  Got one.  ***")
    (vla-put-xscalefactor blkobj x-scale)
    (vla-put-yscalefactor blkobj y-scale)
    (vla-put-zscalefactor blkobj z-scale)
    (vla-put-rotation blkobj rotation)
    (vla-put-Color blkobj color)
    (vla-put-Linetype blkobj linetype)
  )
  (princ)
)
(prompt "\***  Match Block Loaded,  Enter MatchBlock to run.  ***")
(princ)



Be aware that some blocks are created with 0,0 as the insert point and may cause results that are unexpected.
This is because they will rotate and scale from 0,0 and not from a point on the block.
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: match properties for blocks
« Reply #11 on: April 18, 2006, 10:02:53 AM »
Oh, here are some other properties that you may want to change as well.
Code: [Select]
;   Layer = "F1_WINDOWS"
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   PlotStyleName = "ByLayer"
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.

stsevedallas

  • Guest
Re: match properties for blocks
« Reply #12 on: April 18, 2006, 11:02:40 AM »
I added the last four parameters and get..."Error: ActiveX Server returned an error: Parameter not optional"
Before the addition of the last four it worked perfectly.

Here is the code:

Code: [Select]
;;  Match Block
;;  Matches properties from doner block to selected blocks
(defun c:mb (/ srcblk ensel srcobj prop blkobj blk color linetype
               rotation x-scale y-scale z-scale layer linetypescale lineweight plotstylename
                    )

  (if (setq srcblk (car (entsel "\nSelect source block: ")))
    (setq srcobj   (vlax-ename->vla-object srcblk)
          x-scale  (vla-get-xscalefactor srcobj)
          y-scale  (vla-get-yscalefactor srcobj)
          z-scale  (vla-get-zscalefactor srcobj)
          rotation (vla-get-rotation srcobj)
          color    (vla-get-color srcobj)
          linetype (vla-get-linetype srcobj)
          layer    (vla-get-layer srcobj)
          linetypescale (vla-get-linetypescale srcobj)
          lineweight (vla-get-lineweight srcobj)
          plotstylename (vla-get-plotstylename srcobj)

    )
  )

  (while (progn
           (prompt "\nSelect Block to update: ")
           (setq blk (ssget "+.:E:S"))
         )
    (setq blkobj (vlax-ename->vla-object (ssname blk 0)))

    (prompt "\***  Got one.  ***")
    (vla-put-xscalefactor blkobj x-scale)
    (vla-put-yscalefactor blkobj y-scale)
    (vla-put-zscalefactor blkobj z-scale)
    (vla-put-rotation blkobj rotation)
    (vla-put-Color blkobj color)
    (vla-put-Linetype blkobj linetype)
    (vla-put-layer blkobj layer)
    (vla-put-linetypescale blkobj linetypescale)
    (vla-put-lineweight blkobj lineweight)
    (vla-put-plotstylename blkobj plotstylname)

  )
  (princ)
)
(prompt "\***  Match Block Loaded,  Enter MB to run.  ***")
(princ)

<code tags added>
« Last Edit: April 18, 2006, 04:04:22 PM by CAB »

stsevedallas

  • Guest
Re: match properties for blocks
« Reply #13 on: April 18, 2006, 11:16:29 AM »
"plotstylename" was the problem.
I took it out and everything works fine.
Thank you all for the help.

Sdoman

  • Guest
Re: match properties for blocks
« Reply #14 on: April 19, 2006, 06:41:57 AM »
"plotstylename" was the problem.
I took it out and everything works fine.
Thank you all for the help.

I haven't run the code, but I see a typo-bug with the plostylename variable:

...
plotstylename (vla-get-plotstylename srcobj)
...
...
(vla-put-plotstylename blkobj plotstylname)
...