我只是想让这一切对你来说尽可能地无痛。 使用PDXF。lsp,当我选择坐标0,0处的正方形位置和1处的块比例,并且块处于分解状态时,文本屏幕显示如下:
(-1 . <Entity name: 7ef70360>)
(0 . "LWPOLYLINE")
(330 . <Entity name: 7ef59cf8>)
(5 . "11C")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "0")
(100 . "AcDbPolyline")
(90 . 4)
(70 . 1)
(43 . 0.0)
(38 . 0.0)
(39 . 0.0)
(10 -0.288267 0.287769)
(40 . 0.0)
(41 . 0.0)
(42 . 0.0)
(10 -0.287604 -0.288432)
(40 . 0.0)
(41 . 0.0)
(42 . 0.0)
(10 0.288598 -0.287769)
(40 . 0.0)
(41 . 0.0)
(42 . 0.0)
(10 0.287935 0.288432)
(40 . 0.0)
(41 . 0.0)
(42 . 0.0)
(210 0.0 0.0 1.0)
然后我选择DXF数据作为属性定义,我应该有这样的内容:
(-1 . <Entity name: 7ef70368>)
(0 . "ATTDEF")
(330 . <Entity name: 7ef59cf8>)
(5 . "11D")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "SQR TEXT")
(100 . "AcDbText")
(10 -0.158648 0.404835 0.0)
(40 . 0.09375)
(1 . "Square")
(50 . 0.0)
(41 . 1.0)
(51 . 0.0)
(7 . "Romans")
(71 . 0)
(72 . 1)
(11 -0.00016575 0.373585 0.0)
(210 0.0 0.0 1.0)
(100 . "AcDbAttributeDefinition")
(3 . "Text:")
(2 . "TEXT")
(70 .
(73 . 0)
(74 . 1)
如果您将此数据与程序中块定义中的数据进行比较,您应该知道如何安排所有这些。正如我之前在DXF Reference then Entities部分的Developer Help部分中提到的那样,可以找到每一行的含义。每一行都有解释。
请注意,我在程序中搜索块定义,如果图形中不存在块定义,程序将转到块定义函数。
它应该这样开始,表示它是一个块:
(defun BLKLIB_BD ()
(entmake
(list
(cons 0 "block")
(cons 2 SYM)
(cons 10(list 0.0 0.0 0.0))
(cons 70 2)))
实体将跟随,函数以以下内容结束:
(entmake
(list
(cons 0"endblk")
(cons 8 "0")))
(princ))
(princ)
这需要一些时间来适应。 我只是想用我图书馆里的符号。有没有办法将我的目录分到某个地方,以便将该文件路径用于例程?
我的电脑里有一个简单的。我会努力找到它。与此同时,也许其他人会发布一些真正好的东西。 我找不到我提到的例程,因为它在数千个其他文件中丢失了。因此,我修改了我提供的例程,尽管我不确定我是否正确执行了此操作。如果有人发现问题,请随时纠正我。如果块定义不在图形中,我会使用findfile,但除非符号目录位于ACAD搜索支持路径中,否则这将不起作用。我可以发誓这是没有必要的,但现在我不确定。
无论如何,附加的程序有三个外部块,假设它们位于名为C:/Symbols的目录中。该目录需要位于支持路径中,或者可以更改为您想要的名称。这三个块在程序列表中。您也可以将其与为英制单位设置的块比例列表一起更改为所需的值。您可能需要将其更改为公制。
我尽可能多地评论了这个节目,让你了解正在发生的事情。我还删除了图像,以防你决定使用这个程序与你的区块。为你的区块制作图像本身可能是一个完整的线程,所以我不想在这一点上进入它。
程序名为BLKLIB2。具有BLKLIB2的lsp。dcl
命令语法:BLKLIB2
将这些块放在一个名为Symbols的目录中,或者选择您喜欢的内容,只要您在程序中编辑它。
祝你好运,让我知道进展如何。
任何问题,我都乐意回答。
秃鹰
P、 如果有人有更好的东西可以提供,请随意张贴。
-----------------------------------------------------------------------------------------------------------
我只是查找findfile,它仅限于支持搜索路径,如图所示。
圆圈。图纸
三角形。图纸
正方形。图纸
BLKLIB2.dcl
BLKLIB2.lsp
嗨,秃鹰,
我使用了新的例程,更改了符号的路径,并在程序中更改了我的符号名称。我收到了这个错误消息。错误:错误的参数类型:stringp nil。
有什么想法吗?
我不确定你做了哪些改变。你能把你修改过的代码贴出来看看吗?
可能有几件事。您使用的块是否具有属性?您是否从头到尾遵循代码并检查零值? 下面是对例程的更改,请注意,仅更改了文件路径和块的名称。也很抱歉cop粘贴,但由于某些原因,我不能上传到这个论坛。
谢谢
;
; BLKLIB2.lspNote: This program is only a demo example and has no other purpose.
; There are only three blocks in this program for demonstration.
; It only shows a method of creating blocks with a built-in block
; definition using dxf data and inserting them. No external block
; drawings are required.
; This program inserts a selected block to a selected scale factor
; and places it on its own Object layer with Attribute layer. The
; attributes are filled in with no prompting.
;
; Author: Angelo Bozzone
; Original program was SL.lsp created 03|23|06 and modified 05|10|10 to BLKLIB2.lsp
;
; This program requires the following files below to work properly."
; Make sure to have these files together in the same directory."
; Also make sure the the directory is in the AutoCAD Support File Search Path."
;
; BLKLIB2.dcl - AutoCAD Dialog Definition, Size 1KB"
; BLKLIB2.lsp - AutoLISP Application Source, Size 14 KB"
;
; To start this program, At the command prompt type BLKLIB2."
;
; The function directory below list all functions in their assembled order.
;
;========================================================================================
; No.| Function Name | Function Description
;========================================================================================
; F01| C:BLKLIB2 | Program Start.
;----------------------------------------------------------------------------------------
; F02| BLKLIB2_MF | Main Function.
;----------------------------------------------------------------------------------------
; F03| BLKLIB2_RTD | Radians To Degrees.
;----------------------------------------------------------------------------------------
; F04| BLKLIB2_FS | Font Style.
;----------------------------------------------------------------------------------------
; F05| BLKLIB2_CL | Create Layer.
;----------------------------------------------------------------------------------------
; F06| BLKLIB2_CPS | Change Program Settings.
;----------------------------------------------------------------------------------------
; F07| BLKLIB2_RUS | Rsstore User Settings.
;----------------------------------------------------------------------------------------
; F08| BLKLIB2_ET | Error Trap.
;----------------------------------------------------------------------------------------
; | |
;
;/////////////////////////////////////////////////////////////////////////////////
;
; F01 - Program Start.
;
(defun C:BLKLIB2 (/ ALAY AVAL BNAM BSF BSF_LST CPS DCL_ID DEG INPT IANG OLAY RAD SUS SYM_LST UCLK) ; Declare local variables
(setq SUS_LST (list "orthomode" "osmode" "cmdecho" "blipmode" "clayer") ; Save User Settings List
SUS (mapcar 'getvar SUS_LST) ; Save User Settings Variable
TERR *error* ; Store *error
*error* BLKLIB2_ET) ; Goto error trap
(BLKLIB2_MF) ; Goto to Main Function
(princ)) ; Exit quietly
(princ "\nBLKLIB2.lsp Loaded, Type BLKLIB2 to start program.") ; Print message to command line
;
;//////////////////////////////////////////////////////////////////////
;
; F02 - Main Function.
;
(defun BLKLIB2_MF ()
(or BLKLIB2:SYM (setq BLKLIB2:SYM "0")) ; Set default Block Name
(or BLKLIB2:BSF (setq BLKLIB2:BSF "13")) ; Set default Block Scale Factor
(setq SYM_LST (list "plumbingstack" "gooseneckvent" "squarevent") ; Block Names List
BSF_LST (list "1/32\" = 1'" "1/16\" = 1'""3/32\" = 1'" ; Scale Factor List
"1/8\" = 1'""3/16\" = 1'""1/4\" = 1'"
"3/8\" = 1'""1/2\" = 1'" "3/4\" = 1'"
"1\" = 1'" "1-1/2\" = 1'" "3\" = 1'"
"6\" = 1'" "1' = 1'"))
(setq DCL_ID (load_dialog "BLKLIB2.dcl")) ; Load dialog
(if (not (new_dialog "BLKLIB2" DCL_ID)) ; Test for dialog, If not found
(progn ; Then do the following
(ALERT ; Display alert message
(strcat ; Concatenate string
"\nAttention!" ; Start message
"\n"
"\nThe dialog file BLKLIB2.dcl could not be found."
"\nBe sure the dialog file BLKLIB2.dcl"
"\nis in the AutoCAD Support File Search Path.")) ; End message
(exit))) ; Then exit
(start_list "SYM")(mapcar 'add_list SYM_LST)(end_list) ; Fill the Symbols List
(start_list "BSF")(mapcar 'add_list BSF_LST)(end_list) ; Fill the Block Scale List
(set_tile "SYM" BLKLIB2:SYM) ; Set the Block Symbol tile
(set_tile "BSF" BLKLIB2:BSF) ; Set the Block Scale tile
(action_tile "SYM" "(setq BLKLIB2:SYM $value)") ; Get current Block Name value
(action_tile "BSF" "(setq BLKLIB2:BSF $value)") ; Get current Block Scale value
(action_tile "cancel" "(done_dialog)(setq UCLK nil)(BLKLIB2_RUS)") ; Exit program, Set User Click to nil, Restore ;User Settings
(action_tile "accept" "(done_dialog)(setq UCLK T)") ; When OK selected, Set User Click (OK) to true
(start_dialog) ; Start dialog
(unload_dialog DCL_ID) ; Unload dialog
(if UCLK ; If OK selected
(progn ; Then do the following
(cond
((= BLKLIB2:SYM "0") (setq BNAM "plumbingstack")) ; Set the Block Name
((= BLKLIB2:SYM "1") (setq BNAM "gooseneckvent"))
((= BLKLIB2:SYM "2") (setq BNAM "squarevent")))
(cond
((= BLKLIB2:BSF "0") (setq BSF 384)) ; Set the Block Scale Factor
((= BLKLIB2:BSF "1") (setq BSF 192))
((= BLKLIB2:BSF "2") (setq BSF 128))
((= BLKLIB2:BSF "3") (setq BSF 96))
((= BLKLIB2:BSF "4") (setq BSF 64))
((= BLKLIB2:BSF "5") (setq BSF 48))
((= BLKLIB2:BSF "6") (setq BSF 32))
((= BLKLIB2:BSF "7") (setq BSF 24))
((= BLKLIB2:BSF "8") (setq BSF 16))
((= BLKLIB2:BSF "9") (setq BSF 12))
((= BLKLIB2:BSF "10")(setq BSF )
((= BLKLIB2:BSF "11")(setq BSF 4))
((= BLKLIB2:BSF "12")(setq BSF 2))
((= BLKLIB2:BSF "13")(setq BSF 1)))
(cond
((= BNAM "TRIANGLE")(setq ALAY "TRIANGLE TEXT")(setq OLAY BNAM AVAL BNAM)) ; Set the layer attribute layer name, Object layer ;name and Attribute value
((= BNAM "SQUARE")(setq ALAY "SQUARE TEXT")(setq OLAY BNAM AVAL BNAM))
((= BNAM "CIRCLE")(setq ALAY "CIRCLE TEXT")(setq OLAY BNAM AVAL BNAM)))
(BLKLIB2_CPS) ; Change program settings
(BLKLIB2_FS "Romans") ; Set font style to romans Supply One argument
(BLKLIB2_CL ALAY 2 "Continuous") ; Create attribute layer.Supply Three arguments
(BLKLIB2_CL OLAY 1 "Continuous") ; Create object layer. Supply Three arguments
(if
(null
(tblsearch "block" BNAM) ; Search drawing for block.
)
(findfile (strcat "C:\Documents and Settings\ldibiase\Desktop\Symbol Library" BNAM ".dwg")) ; If ;block not found, Find drawing file.
)
(setvar "clayer" OLAY) ; Set the object layer
(setvar "osmode" (nth 1 SUS)) ; Set object snap to saved user object snap
(while ; Program Loop
(setq INPT (getpoint "\nSpecify insertion point: ")) ; Get insertion point
(if (/= INPT nil) ; If insertion point nil
(progn ; Then do the following
(setq IANG (getpoint INPT "\nSpecify orientation angle: ") ; Set insertion angle
INPT (trans INPT 1 0) ; Translate coords
IANG (trans IANG 1 0) ; Translate coords
RAD(angle INPT IANG) ; Get the angle in radians between insertion point ;and insertion angle
DEG(BLKLIB2_RTD RAD)) ; Convert the radians to degrees
(command "._-insert" BNAM INPT BSF BSF DEG)))) ; Insert, Block Name, Insertion Point, Block Scale ;Factor, Block Scale Factor, and Angle in degrees
(BLKLIB2_MF))) ; If insertion point nill return to the dialog
(princ)) ; Exit quietly
(princ)
;
;//////////////////////////////////////////////////////////////////////
;
; F03 - Radians to Degrees.
;
(defun BLKLIB2_RTD (RAD)(* 180.0 (/ RAD pi))) ; Convert radians to degrees
;
;//////////////////////////////////////////////////////////////////////
;
; F04 - Font Style.
;
(defun BLKLIB2_FS (FSTY / TWF TOA PFN BFN) ;Declare arguments and local variables
(setq TWF 1.0 TOA 0.0 PFN "Romans.shx" BFN "") ;Set the font style parameters
(if (null (tblsearch "style" FSTY)) ;Search drawing for font style
(entmake ;Entity make
(list ;List
(cons 0 "STYLE") ;Entity Type
(cons 100 "AcDbSymbolTableRecord") ;Subclass marker
(cons 100 "AcDbTextStyleTableRecord") ;Subclass marker
(cons 2 FSTY) ;Font Style Name
(cons 70 0) ;Flag value
(cons 40 0) ;Fixed text height, 0 if not fixed
(cons 41 TWF) ;Text width factor
(cons 50 TOA) ;Text obliquing angle
(cons 3 PFN) ;Primary font file name
(cons 4 BFN)))) ;Big font file name
(princ)) ;Exit quietly
(princ)
;
;//////////////////////////////////////////////////////////////////////
;
; F05 - Create Layer.
;
(defun BLKLIB2_CL (LNAM LCLR LTYP) ;Declare arguments and local variables
(if (null (tblsearch "layer" LNAM)) ;Search drawing for layer name
(entmake ;Entity make
(list ;List
(cons 0 "LAYER") ;Entiy type
(cons 100 "AcDbSymbolTableRecord") ;Subclass marker
(cons 100 "AcDbLayerTableRecord") ;Subclass marker
(cons 2LNAM) ;Layer name
(cons700) ;Flag value
(cons62LCLR) ;Layer color
(cons 6LTYP) ;Layer linetype
(cons 2901)))) ;Plotting flag
(princ)) ;Exit quietly
(princ)
;
;//////////////////////////////////////////////////////////////////////
;
; F06 - Change Program Settings.
;
(defun BLKLIB2_CPS ()
(setq CPS (list 1 0 0 0))
(mapcar (function setvar)(list "orthomode" "osmode" "cmdecho" "blipmode") CPS)
(princ))
(princ)
;
;//////////////////////////////////////////////////////////////////////
;
; F07 - Restore User Settings.
;
(defun BLKLIB2_RUS ()
(setq *error* TERR)
(if SUS (mapcar 'setvar SUS_LST SUS))
(princ "\nBLKLIB2.lsp has completed and will now restore your settings and exit.")
(princ))
(princ)
;
;//////////////////////////////////////////////////////////////////////
;
; F08 - Error Trap.
;
(defun BLKLIB2_ET (ERRORMSG)
(command nil nil nil)
(if (not (member ERRORMSG '("console break" "Function cancelled")))
(princ (strcat "\nError:" ERRORMSG)))
(if SUS (mapcar 'setvar SUS_LST SUS))
(princ
(strcat "\nBLKLIB2.lsp has encountered a user error!"
"\nProgram will now restore your settings and exit."))
(terpri)
(setq *error* TERR)
(princ))
(princ)
;
;////////////////////////////////////////////////////////////////////// 您没有编辑此条件。
层名称是什么?
对象层名称是什么?
是否有属性?
属性是否在不同的层上?
(cond
((= BNAM "TRIANGLE")(setq ALAY "TRIANGLE TEXT")(setq OLAY BNAM AVAL BNAM))
((= BNAM "SQUARE")(setq ALAY "SQUARE TEXT")(setq OLAY BNAM AVAL BNAM))
((= BNAM "CIRCLE")(setq ALAY "CIRCLE TEXT")(setq OLAY BNAM AVAL BNAM)))
斜杠不正确。
(findfile (strcat "C:\Documents and Settings\ldibiase\Desktop\Symbol Library" BNAM ".dwg"))
你可以这样做,有两种方式。
(findfile (strcat "C:\\Documents and Settings\\ldibiase\\Desktop\\Symbol Library" BNAM ".dwg"))
(findfile (strcat "C:/Documents and Settings/ldibiase/Desktop/Symbol Library" BNAM ".dwg"))
你好,
对不起,我很长时间没来了。我失去了一个家庭成员,我一直在努力使一切井然有序。如果你仍然在那里,我想继续努力,使这再次为我工作。
我会等着看你是否还在附近帮忙,我会给你回复更多信息。
谢谢
页:
1
[2]