Jump to content

Need help with some codes please


Sweety

Recommended Posts

Hello guys . :)

 

Can someone help me with this code ? it doesn't rename the block "FT"

 

(while
 (setq Myblk (tblnext "BLOCK" (null Myblk)))
  (if (eq (cdr (assoc 2 Myblk)) "FT")
    (progn
      (setq entlst (entget (tblobjname "BLOCK" (cdr (assoc 2 Myblk)))))
      (entmod (subst (cons 2 "CO") (assoc 2 entlst)
          entlst
        )
))))

Link to comment
Share on other sites

Thank you LEE .

 

Why you used code 330 ? I see it is 330 Soft-pointer ID/handle to owner object and I can't understand what does it mean .

 

Thankxxxxx

Link to comment
Share on other sites

Why you used code 330 ? I see it is 330 Soft-pointer ID/handle to owner object and I can't understand what does it mean .

 

You can't rename just single block reference without redefining block definition (owner of all blocks with the same name).

Link to comment
Share on other sites

(if (setq ent (tblobjname "BLOCK" "FT"))
   (entmod (subst '(2 . "CO") '(2 . "FT") (entget (cdr (assoc 330 (entget ent))))))
)

 

Wow, I didn't know that :shock:

 

That is so cool :thumbsup:

Link to comment
Share on other sites

Thank you LEE .

 

You're welcome!

 

Why you used code 330 ? I see it is 330 Soft-pointer ID/handle to owner object and I can't understand what does it mean .

 

The 330 DXF Group code is always a pointer to the parent / owner entity, in this case the BLOCK_RECORD entity (AcDbBlockTableRecord object), which is the parent of the BLOCK entity (AcDbBlockBegin object). The AcDbBlockTableRecord object is the object found in the Visual LISP Block Collection and it is this entity / object that should be renamed to rename all references of the block in the drawing.

 

Every AutoCAD Block Definition uses the following entity hierarchy:

 

+-- [color="darkred"]TABLE[/color] ([color="navy"]AcDbBlockTable[/color])
|
+--+-- [color="darkred"]BLOCK_RECORD[/color] ([color="navy"]AcDbBlockTableRecord[/color])
  |
  +--+-- [color="darkred"]BLOCK[/color] ([color="navy"]AcDbBlockBegin[/color])
     |
     +--+-- [i][color="green"]< Block Geometry Entity >[/color][/i]
        |
        +-- [i][color="green"]< Block Geometry Entity >[/color][/i]
        |
       ...
        |
        +-- [i][color="green"]< Block Geometry Entity >[/color][/i]
        |
        +-- [color="darkred"]ENDBLK[/color]

Link to comment
Share on other sites

I did some research :

 

blocks

 

[color=brown]
 (if (setq ent (tblobjname "BLOCK" "FT"))
     (entmod (subst '(2 . "CO") '(2 . "FT") (entget (cdr (assoc 330 (entget ent))))))
 )[/color]

also

[color=brown]
 (if (setq ent (cdr (assoc -2 (tblsearch "BLOCK" "FT"))))
     (entmod (subst '(2 . "CO") '(2 . "FT") (entget (cdr (assoc 330 (entget ent))))))
 )[/color]

layers

 

"0" layer can't be renamed, but color can be set to it (changed to "red" - color 1)

 (if (setq ent (tblobjname "LAYER" "0"))
     (entmod (subst '(62 . 1) '(62 . 7) (entget ent)))
 )

views

 

Empty table view (tblnext "VIEW" T) => nil

Firstly create view "MR"

 (if (setq ent (tblobjname "VIEW" "MR"))
     (entmod (subst '(2 . "VR") '(2 . "MR") (entget ent)))
 )

ltypes

 

"Continuous" ltype can't be modified so you have to load new ltype

Firstly load ltype "Dashed"

 (if (setq ent (tblobjname "LTYPE" "Dashed"))
     (entmod (subst '(2 . "MR") '(2 . "Dashed") (entget ent)))
 )

styles

 

"Standard" style can't be renamed, but font can be set to it (changed to "simplex.shx")

 (if (setq ent (tblobjname "STYLE" "Standard"))
     (entmod (subst '(3 . "simplex.shx") '(3 . "arial.ttf") (entget ent)))
 )

ucss

 

Empty table ucs (tblnext "UCS" T) => nil

Firstly save ucs "MR"

 (if (setq ent (tblobjname "UCS" "MR"))
     (entmod (subst '(2 . "VR") '(2 . "MR") (entget ent)))
 )

dimstyles

 

"Standard" dimstyle can't be renamed and modified

Firstly save dimstyle "MR"

 (if (setq ent (tblobjname "DIMSTYLE" "MR"))
     (entmod (subst '(2 . "VR") '(2 . "MR") (entget ent)))
 )

vports

 

Empty table vport (tblnext "VPORT" T) => nil

Firstly create vport "MR"

 (if (setq ent (tblobjname "VPORT" "MR"))
     (entmod (subst '(2 . "VR") '(2 . "MR") (entget ent)))
 )

appid

 

"ACAD" appid can't be modified, so this won't work

[highlight]
 (if (setq ent (tblobjname "APPID" "ACAD"))
     (entmod (subst '(2 . "MR") '(2 . "ACAD") (entget ent)))
 )[/highlight]

M.R.

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...