Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/19/2024 in all areas

  1. Keep in mind a field is linked to an object in a drawing. You have to insert the block first then create the field for it. If you make copies of that block and the field all those fields will reference the original insertion not the copied insertions. If you copy an object with field to another drawing the field will no longer work because the reference has to be set up in the current drawing. Plenty of useful code out there for labeling blocks using fields just keep in mind they are limited by being directly linked to a specific object in a specific drawing. http://www.cadtutor.net/forum/showthread.php?51254-Block-s-name-to-FIELD-(based-on-existing-lisp)&p=347968&viewfull=1#post347968
    2 points
  2. @choupi1968 @fuccaro 's code works fine. With your exemple, you must just remove "X" at (ssget) and change the tag "ADDRESS" to "ORDRE""
    2 points
  3. Hi pkenewell! I have not. A great snippet for future study is this one. Thank you!
    1 point
  4. Have you attempted to do any code? Here are some hints: ;; Create a selection set of the Text Objects and Text Style: (setq ss (ssget "X" '((0 . "*TEXT")(7 . "OldStyleName")))) ;; If the Style table does not have the new Style Name, Make it. (if (not (tblsearch "STYLE" "NewStyleName")) (command "._-style" "NewStyleName" "arial.ttf" 0.0 1.0 0.0 "_n" "_n") ) ;; If the selecction set is found: (if ss ;; Iterate through the selection set - set counter to the length of the set: (repeat (setq cnt (sslength ss)) ;; Get the entity list of item in selection set. (setq el (entget (ssname ss (setq cnt (1- cnt)))) ;; Substitute the new Text Style name in place of the old one. el (subst (cons 7 "NewStyleName") (assoc 7 el) el) ) ;; Modify the entity. (entmod el) ) ) ;; Purge the old Style. (command "._-purge" "_ST" "OldStyleName" "_N")
    1 point
  5. It's entirely possible. You simply need to retrieve the ID of the object concerned. You can rely on the text provided in the dialog box when designing the field in manual mode, you just have to be careful to double the "\" character in the lisp code so that it is correctly interpreted. In lisp we can even have characteristics not accessible in a dialog box, an example of code to have the volume of a 3D solid (impossible to have this property in a dialog box) (vl-load-com) (defun c:Label_Volume ( / js htx AcDoc Space n obj ename pt alpha nw_obj) (princ "\nSelect solid.") (while (null (setq js (ssget (list '(0 . "3DSOLID") (cons 67 (if (eq (getvar "CVPORT") 1) 1 0)) (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model")) ) ) ) ) (princ "\nAren't solid!") ) (initget 6) (setq htx (getdist (getvar "VIEWCTR") (strcat "\nGive the height of the text <" (rtos (getvar "TEXTSIZE")) ">: "))) (if htx (setvar "TEXTSIZE" htx)) (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object)) Space (if (= 1 (getvar "CVPORT")) (vla-get-PaperSpace AcDoc) (vla-get-ModelSpace AcDoc) ) ) (vla-startundomark AcDoc) (repeat (setq n (sslength js)) (setq obj (ssname js (setq n (1- n))) ename (vlax-ename->vla-object obj) ) (initget 1) (redraw obj 3) (setq pt (getpoint "\nInsertion point?: ") alpha 0.0 nw_obj (vla-addMtext Space (vlax-3d-point pt) 0.0 (strcat "{\\fArial|b0|i0|c0|p34;" "%<\\AcObjProp.16.2 Object(%<\\_ObjId " (itoa (vla-get-ObjectID ename)) ">%).Volume \\f \"%lu2%pr2%ps[V=,m³]\">%" ) ) ) (redraw obj 4) (mapcar '(lambda (pr val) (vlax-put nw_obj pr val) ) (list 'AttachmentPoint 'Height 'DrawingDirection 'InsertionPoint 'Layer 'Rotation) (list 5 (getvar "TEXTSIZE") 5 pt (getvar "CLAYER") alpha) ) ) (vla-endundomark AcDoc) (prin1) )
    1 point
  6. Having a hard time understanding why you're moving a Civil 3D drawing, are you trying to convert a drawing from one coordinate system to another? It may be simpler to start a new drawing with the coordinate system you want and insert the other drawing. I've only used Civil 3D with one Map 3D projection zone and have never had a need to move a drawing. When you say the level changes are you talking about the elevations? Map 3D moving from national grid to a local grid
    1 point
  7. i think this goes in the direction you want, but this does not change some dimension colors and similar things. Also it doesnt take the transparency value from the layer. I added comments on the side so you can understand whats supposed to happen (defun c:layZ (/ layerswap doc) ;| Sets object layer by string. Creates if neccessary @Param obj \<vla-obj> @Param str \<string> name of the layer the object should be set to. @Returns ? |; (defun layerswap (obj str / makelayer doc oldlayer oldlock) (defun makelayer (str / layers) (setq layers (vla-get-layers doc)) (if (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list layers str)))) t (vla-add layers str) ) ) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (if (makelayer str) (progn (setq oldlayer (vla-item (vla-get-layers doc)(vla-get-layer obj))) (setq oldlock (vla-get-lock oldlayer)) (vla-put-lock oldlayer :vlax-false) (vla-put-layer obj str) (vla-put-lock oldlayer oldlock) ) ) );defun (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for item (vla-get-modelspace doc) ; goes trough every drawing object in model area (if (vlax-property-available-p item 'layer t) ; checks if item has the property "layer" (foreach property '("Color" "LineType" "LineWeight") (if (vlax-property-available-p item property t) ;checks if the item has property (vlax-put-property item property (vlax-get-property (vla-item (vla-get-layers doc)(vla-get-layer item)) property)) ;gets layer property and sets it to item ) ) ) (layerswap item "0") ; sets obj layer to 0 ) )
    1 point
  8. @Clint Please upload a sample dwg with a few entities before and after
    1 point
  9. I leave it up to you to modify this to your liking, just arm (initget) with the keys that suit you. For my part, I prefer to leave the choice free because the options could be numerous, for example a conversion from centimeter to inch. Another thing I forgot to mention is that it is possible to reset the level points after the fact: simply move them (reference point included) and do a regen/regenall to update the fields. No need to erase them and start again in case of wrong position..
    1 point
  10. @Tsuky thank you very much for the improvement. I add to the first string "scale"... (defun c:LEVEL-PT ( / pt ss e_ref ang dxf_210 scale factor suffix obj# obj) and you can make a backlight to select the coefficients 0.01(cm) and 0.001(m) for M100 and 0.0005 (m for M50) (setq factor (getreal "\nMeasurement conversion factor?[1.0/0.01/0.001/0.0005]: "))
    1 point
  11. Maybe start with a clean DWT way simpler than wading through hundreds of variables.
    1 point
  12. Need dwg so can look at objects.
    1 point
  13. I think I have improved the code for correct operation. Possibilities for the reference block Provide the reference point Provide an angle for the block Provide an overall insertion scale for the block Provide a conversion factor for the measurement made (for example if the drawing is a centimeter, a factor of 0.01 will give the measurement in meters) And an optional suffix (as if the example above, we can put "m" to correlate.) Then we provide as many points to rate as we want. Normally can work in any UCS. If you want to continue a level dimension already carried out, simply choose the [Select] option when requesting the reference level and choose the reference dimension "0.00" to set up dimension linked to this reference (There can be several reference levels in the drawing) This retrieves the angle of the block, the scale of the block, the UCS of the block but not the conversion factor or the suffix: which allows you to make, for example, dimensions in centimeters and meters from the same reference point . I hope this will suit you... level_pt.lsp
    1 point
  14. I am a bit confused now. The program I wrote should sort those attributes, whatever they contains.
    1 point
  15. Explain more what it is your doing when moving.
    1 point
  16. 1 point
×
×
  • Create New...