ElCidCampeador 发表于 2022-7-6 21:50:10

VBA Autocad: How to find lines

I'm trying to write a VBA code that searches in a general drawing all lines that have a specific length and slope. Then, every time it finds that line in the drawing, it will write next to a specific text, for example "line". Do you think it's possibile? Any idea? Thanks

Tyke 发表于 2022-7-6 22:04:23

In principle what you want to do is perfectly possible.
 
You search the current drawing filtering on lines to create a selection set. Then loop through the selection set and write your text at your desired position.

BIGAL 发表于 2022-7-6 22:12:20

As VBA
 

Dim FilterDXFCode(0) As IntegerDim FilterDXFVal(0) As VariantFilterDXFCode(0) = 0FilterDXFVal(0) = "LINE"Set SS = ThisDrawing.SelectionSets.Add("Linelens")SS.Select acSelectionSetAll, , , FilterDXFCode, FilterDXFValFor Cntr = 0 To SS.Count - 1'now get the length etc and do something
As lisp

(setq ss (ssget (list (cons 0 "Line"))))(repeat (setq x (sslength ss))(setq obj (vlax-ename->vla-object (ssnamess (setq x (- x 1)))))(vla-get-length obj)(princ "\n"))

maratovich 发表于 2022-7-6 22:28:28

Can.
Write all the requirements, and attach an example.

ElCidCampeador 发表于 2022-7-6 22:34:14

Thank you all! It works...!

BIGAL 发表于 2022-7-6 22:47:31

What worked ? You dont have to post the code just how, others may want the same answer.

ElCidCampeador 发表于 2022-7-6 22:50:31

I used your idea Bigal, vba
页: [1]
查看完整版本: VBA Autocad: How to find lines